Copied to clipboard

Flag this post as spam?

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


  • Anders Aleborg 35 posts 67 karma points
    Jan 22, 2015 @ 14:57
    Anders Aleborg
    0

    In footer?

    Hi,

    is it possible to place the twitter and facebook feeds in the Master template? With the current solution we have to authorize every single page on the website

  • Anders Bjerner 487 posts 2990 karma points MVP 8x admin c-trib
    Jan 22, 2015 @ 23:37
    Anders Bjerner
    100

    Hi Anders,

    Yes, that is indeed possible.

    If you have the property on each page, I assume you're doing something like this in your template/view:

    // Get the OAuth information stored in the property
    FacebookOAuthData facebook = Model.Content.GetPropertyValue("facebook") as FacebookOAuthData;
    

    That takes the property on the current page.

    The fix
    In your content tree, you will have a node representing the site, so if you add the property here rather than on each page, you can update your code to something like:

    // Get the OAuth information stored in the property
    FacebookOAuthData facebook = Model.Content.AncestorOrSelf(1).GetPropertyValue("facebook") as FacebookOAuthData;
    

    The code will now take the current page, and then find its ancestor at level 1 (assuming that site node is the topmost node). You can put this code in your master template/view, our even isolate it further in a partial view.

    Hope this solves your problem ;)

  • Anders Aleborg 35 posts 67 karma points
    Jan 27, 2015 @ 10:42
    Anders Aleborg
    0

    Thanks, that did the trick!

Please Sign in or register to post replies

Write your reply to:

Draft