Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • dave 36 posts 149 karma points
    Apr 29, 2015 @ 01:24
    dave
    0

    utwit not on home page

    I was able to follow the instructions to get the view latesttweets.cshtml showing on the home page.

    I placed the reference to the partial view in the master page

    @Html.Partial("/Views/Partials/latesttweets.cshtml")
    

    This works fine.

    The problem is that when a user navigates away from the home page i lose the tweets.

    I have the twitter oauth property associated with the Home document type. I suspect that is why when users go to another page it no longer works.

    Which document type do I associate the oauth twitter property with so that when users navigate to another page the latesttweets.cshtml still works?

    thx

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Apr 29, 2015 @ 08:41
    Dennis Aaen
    100

    Hi Dave,

    You just need to make some small changes to the view latesttweets.cshtml.

    You just need to add .AncestorOrSelf(1) into the Model.Content so the full code with the changes would look like this:

    if (Model.Content.AncestorOrSelf(1).HasValue(twitterOAuthPropertyAlias))
        {
            var config = Model.Content.AncestorOrSelf(1).GetPropertyValue(twitterOAuthPropertyAlias);
            var tweets = uTwit.GetLatestTweets(config, numberOfTweetsToDisplay, includeReplies, includeRetweets);
            if (tweets != null)
            {
                @Html.Partial("TweetList", tweets)
            }
       }

    Hope this helps,

    /Dennis

  • dave 36 posts 149 karma points
    Apr 29, 2015 @ 13:31
    dave
    0

    Great thank you. That worked. Can you help me understand something?

    So I like many things of Umbraco however what is troublesome is...how would i know that answer? (Am I missing some documentation or some logic on how Umbraco works?) Where would I have looked for that type of answer?

    I did get it to work through a few hours of trial and error by hardcoding in the twitter access token/token secret etc. I did not like this approach but I found i was unable to get the uTwit config parameter.

    thx

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Apr 29, 2015 @ 13:54
    Dennis Aaen
    0

    Hi Dave,

    In Umbraco you can access data from different axes. Try to see this documentation, but it is bit old https://our.umbraco.org/documentation/reference/templating/macros/razor/using-razor-axes, so if you are using Partail view macros or partial views the current page if you are using dynmic Razor is CurrentPage, if you are using strongly typed Razor then the current page is Model.Content. 

    Perhaps these cheat sheets https://our.umbraco.org/projects/developer-tools/umbraco-v6-mvc-razor-cheatsheets can help to get an overview over the different methods that you have in Razor. I know it says for Umbraco 6, but so be fine for Umbraco 7 also. It´s just some PDF files with an overview.

    Hope this answers your questions, else don't hesitate to ask again.

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft