Copied to clipboard

Flag this post as spam?

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


  • Paul Sørensen 304 posts 650 karma points
    Dec 26, 2009 @ 23:58
    Paul Sørensen
    0

    Re-use of content

    Hi

    I have a node which I would like to use in more that one place. Is that possible when the document contains a macro. I read somewhere that the macro was a problem but is that still the case and if not - how can it be done?

    Thanks
    Paul S

  • Martijn van der Put 44 posts 65 karma points
    Oct 22, 2010 @ 10:09
    Martijn van der Put
    0

    Hello Paul,

    a bit late this reaction, but it is possible to re-use content when it contains a Macro.

    In my own solution (Version 4.5.x) I have the following solution: Template 1 -> Macro -> Template 2 and both my Templates contain a Macro.

    Template 1 contains a MultiPicker field which is linked to a list of items of Template 2.
    The Macro in Template 1 loops through the values of the MultiPicker field and uses the RenderTemplate method ( <xsl:value-of select="umbraco.library:RenderTemplate($currentPage/snippets)" disable-output-escaping="yes"/> ) to render Template2.

    My Template 2 contains another Macro which retrieves the needed fields.

  • Claushingebjerg 936 posts 2571 karma points
    Oct 22, 2010 @ 13:15
    Claushingebjerg
    0

    @Martin

    Could you elaborate on this, as i dont really get it. I need to reuse an entire section from one language version a site on another... something like 70 pages in a page/ subpage structure which uses 3 different templates...

    i dont really understand how to implement your solution in this scenario...

    Hope you can help me out. Ive been trawling for solutions on reusing content, but it all seems somewhat cryptic.

     

  • Martijn van der Put 44 posts 65 karma points
    Oct 22, 2010 @ 21:48
    Martijn van der Put
    0

    Hello Claus,

    my solutions is quite simple, follow the steps below to accomplish my solution for content re-use:

    - In my situation I have a sidebar-page where I want to place different content-parts that are stored as items in a different location of my website.
    - In the sidebar-page where you want to display the content in the side, add a link-field to the document-type, for example an Ultimate Picker-field and make sure the "parent id" in the Ultimate Picker field is set to the folder that contains all your re-usable content.
    - Create a new document type "Banner" (these banners will be shown in the sidebar) and also create the template:

    -My template looks like this:
    <
    %@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
    <
    asp:content ContentPlaceHolderId="ContentPlaceHolderDefault" runat="server">
    <div id="banner">
      <umbraco:Macro alias="Banner" runat="server" />
    div>
    >

    - The document type "Banner" contains an Image-field.
    - Now create the Macro and XSLT-file "Banner" and in the XSLT-file you just get the
    image-field from the currentPage and render the image  and its html tags like you
    do with a normal image.

    - Create a Macro and XSLT-file "Sidebar"
    In my XSLT file for the sidebar I execute the following code:
    <
    xsl:value-of select="umbraco.library:RenderTemplate($currentPage/BannerList)" disable-output-escaping="yes"/>

    - The currentPage is my Sidebar page with my Ultimate Picker field BannerList. (In this case I have only one item selected in my Ultimate Picker and I do not need to split and loop through the values of the Ultimate Picker field)
    - In the template of my Sidebar-page I call the Sidebar Macro:
     
    <div id="sideBar">
        
    <umbraco:Macro alias="Sidebar" runat="server" />
      div>

    This should do the trick.
    In short, my sidebar-page calls the Macro "Sidebar", this Macro reads the selected document id's from the Ultimate Picker field and uses the RenderTemplate function to render the document(s).

    Regards,
    Martijn

     

Please Sign in or register to post replies

Write your reply to:

Draft