Copied to clipboard

Flag this post as spam?

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


  • Gavin Roberts 4 posts 24 karma points
    May 27, 2013 @ 16:16
    Gavin Roberts
    0

    umb Business Frontpage Blog.xslt

    Hi all
    My first question. I am trying to get the blog umb Business Frontpage Blog.xslt to work on the master template so the list of blogs appears in footer of every page. The following code has it working on home page but stops working on internal pages.

    <xsl:for-each select="$currentPage/umbBlog//umbBlogPost [@isDoc and string(umbracoNaviHide) != '1']">

    Is there a way of getting the macro to work on all pages site wide?

    Thanks

    Gavin

  • Istvan Pszota 59 posts 191 karma points
    May 27, 2013 @ 19:51
    Istvan Pszota
    1

    Hi Gavin!

     

    It is because $currentPage is a dynamic node variable.

    It always point to the node of the current page.

    The reason why your script runs well on the home page is because your blog posts probably located at

    homePage/umbBlog/umbBlogPost

    thus when you are visiting an internal site, the above code tries to find your blog posts at

    someIntenralPage/umbBlog/umbBlogPost - but can't find it....

     

    Not the best, but it worked for me:

    create a new variable, for example:

    <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(1163)"/>
    

    ('1163' is the id of your homePage)

    then use it like:

     <xsl:for-each select="$node/umbBlog/umbBlogPost [@isDoc and string(umbracoNaviHide) != '1']">

     

    Hope this helps! ;)

    Istvan

     

     

  • Gavin Roberts 4 posts 24 karma points
    May 27, 2013 @ 20:02
    Gavin Roberts
    0

    Thanks Istvan. That worked perfectly!

    Best wishes

    Gavin

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    May 27, 2013 @ 20:04
    Chriztian Steinmeier
    0

    Hi Gavin,

    I always create a $siteRoot variable for purposes like this, which points to the top node of the site (even works in multi site solutions):

    <xsl:param name="currentPage" />
    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />

    Then I can use that later as the base for selections that aren't tied to the current page:

    <xsl:for-each select="$siteRoot/umbBlog//umbBlogPost[@isDoc][not(umbracoNaviHide = 1)]">
        <!-- etc... -->
    </xsl:for-each>
    
    (If your Home node isn't on level 1, you'll need to adhust that in the variable)

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft