Copied to clipboard

Flag this post as spam?

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


  • Raheel 62 posts 81 karma points
    Sep 15, 2010 @ 08:53
    Raheel
    0

    Using Macro's on Multiple Pages - Please help

    Hello there,

    The structure I have on my templating is:

    Master Template

    • HomePage
    • ContactPages

    There are also Document Types as:

    • HomePage
    • ContentPages

    Now what I want to do is display "Related Links" preoperty in Umbraco into footer of All Templates.
    No matter if its HomePage or ContentPages I still want this to be displayed.

    What I have done is:

    1. I create a new tab in HomePage Document Type called "SitemapFooter".

    2. Added a new Property as "sitemapFooterContent" and added the type as "Related Links".

    3. I have added content on the Related Links which is on SitemapFooter tab of my Home Page template. HomePage template is only being used once so there is only one page called Home.aspx

    4. Created a XSLT and AutoCreate Macro - Name it SitemapFooter and choose template as "Related Links".
    5. On the XSLT file I have changed
      <xsl:variable name="propertyAlias" select="string('sitemapFooterContent')"/>

    6. Added a Content Area Place holder on Master Template where the SitemapFooter needs to be naming it SitemapFooterPH

    7. Added the SitemapFooterPH content area on HomePage template
    8. Added the Macro SitemapFooter inside the SitemapFooterPH content area.

     

    Now my issue is, this content (Related Links) results will show on anypage that has HomePage as their template.
    I want that Related Field to be shown on all template.

    I have tried reading online, even had a look at the videos but cannot find any resource.

     

    In short, what I want to do is:

    1. To be able to edit "Related Links" field form some where
    2. To be able to show the "Related Links" on all templates at the bottom (meaning adding it to master template)


    Can some one guide me how do I do this, I am new to Umbraco so dont know too much.

     

    Thanks You!
    Raheel

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Sep 15, 2010 @ 09:26
    Matt Brailsford
    0

    Hi Raheel,

    I'm assuming you'll want different related links per page, so what I would suggest is to create a master document type which works similar to a master template, but for document types. With this, you can define your SiteMapFooter tab on your master doc type, then when you create a new doc type, you can set it's master doc type, to that doc type. This will then make the SiteMapFooter tab available on all doc types which use that master doc type (so you don't have to create it again on each new doc type).

    Hope that make sence =)

    Matt

  • Raheel 62 posts 81 karma points
    Sep 15, 2010 @ 13:14
    Raheel
    0

    Hi Matt,

    Thanks for that. I am wondering how do I set a DocumentType as a master.. Sorry I am new to Umbraco but getting there.

    Thanks
    Raheel

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Sep 15, 2010 @ 13:21
    Matt Brailsford
    0

    Hi Racheel.

    No problem.

    Just create your master doc type as usual, and then to create your sub doc type, in the create dialog where you enter the name of your doc type, select your master doc type from the "Master" dropdown list.

    Your sub doc type will now inherit all tabs and properties from your master doc type.

    Matt

  • Raheel 62 posts 81 karma points
    Sep 16, 2010 @ 01:28
    Raheel
    0

    Thanks for that! All sorted and working.

  • Raheel 62 posts 81 karma points
    Sep 16, 2010 @ 06:39
    Raheel
    0

    Hi Matt,

    I have got the master documents working etc... but I still want somehow to be able to include a Macro in Multiple Template.

    What I mean is, I want one Related Link and its information will be displayed on the footer of every page.

     

    What is the best possible way?

    Thanks
    Raheel

  • Rich Green 2246 posts 4008 karma points
    Sep 16, 2010 @ 07:50
    Rich Green
    0

    Hi Raheel,

    With any piece of functionality or design that you want to appear automatically on each page you need to put this functionality into a master template.

    This is explained here, although it's an older article http://umbraco.org/documentation/books/templates-explained

    It's also explained in Umbraco.tv http://umbraco.org/documentation/videos/for-site-builders/templating/using-master-templates

    The idea is that the master template will always have the related links macro, this macro calls an XSLT file which knows which page the user is on by the use of a variable called '$currentPage', by using this variable you can get XSLT to show the related links for the page the user is visiting.

    Hope this helps, best of luck

    Rich

  • Raheel 62 posts 81 karma points
    Sep 16, 2010 @ 08:21
    Raheel
    0

    Hi Rich,

    I did do that.

    Templates are:

    APSMaster
    - ContentPage
    - HomePage
    - OneColumn

    Document Type:

    APSMaster
    - ContentPage
         - OneColumn
    - HomePage

    FooterLinks (Does not have a master document type)

    I created a property of Related Links in FooterLinks document type.
    Created a XSLT / Macro and linked it to FooterLinks

    Added the macro to ASPMaster template.

     

    Now there are many pages that have ContentPage as template, some have OneColumn as template and Index Page is assigned to HomePage template.

     

    It does not show.

  • Rich Green 2246 posts 4008 karma points
    Sep 16, 2010 @ 08:30
    Rich Green
    0

    Hi Raheel,

    Your set up looks correct.

    Try adding some text to your xslt file outside your logic to make sure that the macro is getting called, just something like "test text" this will tell you if your macro is being called.

    If you see this text on every page then there's something wrong with your XSLT, if not then you've got something wrong with your set up.  

    Also you could post your xslt code here.

    Rich

  • Raheel 62 posts 81 karma points
    Sep 16, 2010 @ 08:35
    Raheel
    0

    Hi Rich,

    Here is the XSLT code I have:

     

    version="1.0" encoding="UTF-8"?>
    DOCTYPE xsl:stylesheet [  ENTITY nbsp " ">]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


      <xsl:output method="xml" omit-xml-declaration="yes" />

      <xsl:param name="currentPage"/>
      
      
      <xsl:variable name="propertyAlias" select="string('footerLinks')"/>
      
      <xsl:template match="/">

        
        <ul>
          <xsl:for-each select="$currentPage/* [name() = $propertyAlias and not(@isDoc)]/links/link">
            <li>
              <xsl:element name="a">
                <xsl:if test="./@newwindow = '1'">
                  <xsl:attribute name="target">_blankxsl:attribute>
                xsl:if>
                <xsl:choose>
                  <xsl:when test="./@type = 'external'">
                    <xsl:attribute name="href">
                      <xsl:value-of select="./@link"/>
                    xsl:attribute>
                  xsl:when>
                  <xsl:otherwise>
                    <xsl:attribute name="href">
                      <xsl:value-of select="umbraco.library:NiceUrl(./@link)"/>
                    xsl:attribute>
                  xsl:otherwise>
                xsl:choose>
                <xsl:value-of select="./@title"/>
              xsl:element>
            li>
          xsl:for-each>
        ul>

        
        <xsl:value-of select="umbraco.library:Item($currentPage/@id,$propertyAlias,'')" />

      xsl:template>

    xsl:stylesheet>

     

     

    --

    The related link field is called footerLinks

    Thanks
    Raheel

  • Rich Green 2246 posts 4008 karma points
    Sep 16, 2010 @ 09:19
    Rich Green
    0

    Do you get an empty ul's in your template?

    <ul></ul>

    Rich

Please Sign in or register to post replies

Write your reply to:

Draft