Copied to clipboard

Flag this post as spam?

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


  • Anita Thagaard Kristensen 33 posts 53 karma points
    Aug 24, 2010 @ 17:08
    Anita Thagaard Kristensen
    0

    Re use existing Content and child nodes

    Hi

    Does anyone knows how to reuse content indstead of copy paste?

    Anita

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Aug 24, 2010 @ 17:23
    Ismail Mayat
    1

    Anita,

    In the past I have done it by creating a blank node and that has source node parameter which is content picker. With that content picker i set to the target node.  In the template i use xslt macro that for the current page gets the source node id and does GetXmlNodeById and writes out a given property normally bodyText.

    Regards

    Ismail

  • Anita Thagaard Kristensen 33 posts 53 karma points
    Aug 24, 2010 @ 18:51
    Anita Thagaard Kristensen
    0

    Hi Ismail

    Can you tell me step for step how to do it. I'm sorry I'm a newbie

    Regards

    Anita

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Aug 24, 2010 @ 21:24
    Jan Skovgaard
    0

    Hi Anita

    The content you need to reuse is that sidebar content or something like that? And do you have access to the settings and developer settings or do you only add content to the site?

    If you have administrator rights you can do as Ismail is saying. I would do it in a similar fashion. You could for instance do the following:

    1) Go to the "Settings" section, add a new property to your document type. You could for instance name it "reauseable content" and choose "content picker" for it's document type.

    2) In your content section, create the content that should be reused on multiple sites.

    3) Select that specific node on those pages that need to display the same content.

    4) Create a XSLT macro in the developer section where you can fetch the content by using the GetXmlNodeById extension. You can see the Wiki for documentation on how to use this.

    I hope this clarifies the steps a bit?

    /Jan

  • Anita Thagaard Kristensen 33 posts 53 karma points
    Aug 25, 2010 @ 09:54
    Anita Thagaard Kristensen
    0

    Hi Jan

    I have done what you wrote until point 3, but I can't find the documentation you wrote about in point 4. Can you please give me the link.

    Regards

    Anita

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Aug 25, 2010 @ 09:58
    Jan Skovgaard
    0

    Hi Anita

    Hmm I thought I had copy/pasted it - must have been tired :-)

    Here it is: http://our.umbraco.org/wiki/reference/umbracolibrary/getxmlnodebyid-%281%29

    /Jan

  • Anita Thagaard Kristensen 33 posts 53 karma points
    Aug 26, 2010 @ 09:45
    Anita Thagaard Kristensen
    0

    Hi Jan

    I have tried to find how to use your link and where to place it, but I can't find how to do.

    The reason for me to need this is, that I'm working on an existing homepage which is made of another person. The existing page use flash player and because of that, it can't be seen by people that use mobile phones.

    My wish is to reuse the pages where there are flash inside and replace the flash with pictures without flash. When I copy past the content, I don't get all the menu from the original page and I can't find the lost menu in the code from the original page.

    So I hope you can help me with that.

    Regards

    Anita

  • Anita Thagaard Kristensen 33 posts 53 karma points
    Aug 26, 2010 @ 16:30
    Anita Thagaard Kristensen
    0

    Hi

    Isn't there anyone that can help me with the above mentioned problem. I'm totally stocked and newbie.

    Anita

     

  • Dibar 92 posts 74 karma points
    Aug 26, 2010 @ 18:58
    Dibar
    0

    Hi ATK!

      I call what your trying to do the same thing, "reusable content". It can be complex, because umbraco is so powerful, but the concepts are pretty straightforward.  

    The easiest way to reuse content I know of is to first create a Document Type in the Settings section. When you create the document, by right-clicking on Document Types, uncheck the Create a Template checkbox. We will be creating Content without a template. Give this document a property, and make the Type a Textbox Multiple or Simple Editor. Name the Document Type 'Embeddable' (or such) and the proprety 'Primary' and alias 'primary' for illustration.

    Now, in the Content section, create a new Embeddable. If you want you can create a special document type to act as a folder and hold your Embeddables. It probably should not be under your main entry page node, but a second node under Content.

    Add content to the primary property, and publish the document.

    Now go to the Developer section. Create a new Xslt file, and do check the make a macro box.

    
    
    
      <?xml version="1.0" encoding="UTF-8"?>
    <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"
            exclude-result-prefixes="msxml umbraco.library">
    <xsl:output method="xml" omit-xml-declaration="yes" />
    <xsl:param name="currentPage"/>
    <xsl:variable name="NodeId" select="/macro/nodeid"/>
    <xsl:template match="/">
      <xsl:if test="$NodeId!= ''">
        <xsl:value-of select="umbraco.library:GetXmlNodeById($NodeId)/primary" disable-output-escaping="yes"/>
      </xsl:if>
    </xsl:template>
    </xsl:stylesheet>
    
    
    
    

    That should do as the Xslt. All it is doing is finding the node by the id (which we will setup), and displaying it, unescaped.

    Find the related Macro under Macros. Add a parameter, Name 'NodeId', alias 'nodeid' to match our xslt, and choose a content picker for Type. Save the macro, and we are set.

    In a Masterpage Template or Richtext Editor, click the insert umbraco macro button, and select your macro. Use the Content Picker to select your Embeddable, click out and Save/Publish.

    The text in you Embeddable can now be inserted in this manner into templates and content, or variations of the Xslt can do wonders. Multiple properties on embeddables is possible, and useful, but I keep them 'lookless' or without templates, and format in xslt and css.

    Also explore the blog package for some hints and tips concerning organization etc.

    Hope that works, let me know any trouble.

    EDIT: It sounds like, specific to your issue, you would place in your template a macro to call xslt which would determine which browser or whatever, and decide what to node to 'embed".

  • Anita Thagaard Kristensen 33 posts 53 karma points
    Aug 27, 2010 @ 10:23
    Anita Thagaard Kristensen
    0

    Hi Xander

    I followed you all the way down to where I should go into a Masterpage Template. This Masterpage.. can that be the one called Home Master. Home Master is the Masterpage for the first side on the web. (I use to call that default in normaly html).?

    You wrote that I should use the Content Picker to select my Embeddable. How do I find that in the popup window that appears after you have selected the macro?

    I got stocked here and I also got an :

    Page not found

    No umbraco document matches the url 'http://localhost/en/Brakes(2).aspx'

    umbraco tried this to match it using this xpath query'/root/node/node [@urlName = "en"]/node [@urlName = "brakes(2)"] | /root/node [@urlName = "brakes(2)"]')

    This page can be replaced with a custom 404 page by adding the id of the umbraco document to show as 404 page in the /config/umbracoSettings.config file. Just add the id to the '/settings/content/errors/error404' element.

    For more information, visit information about custom 404 on the umbraco website.

    Anita

  • Anita Thagaard Kristensen 33 posts 53 karma points
    Aug 27, 2010 @ 11:43
    Anita Thagaard Kristensen
    0

    Hi Xander

    If I change /config/umbracoSettings.config line

    <errors>
    <error404>1</error404> to <error404>2278</error404>
    </errors>

    then I can see the new page but I still don't have the same output of menu's on the page as I have on the orginal page.

    How can I get the last menu into the new page?

    Anita

  • Dibar 92 posts 74 karma points
    Aug 27, 2010 @ 17:02
    Dibar
    0

    Yes, it sounds like you are directing all unfound requests to the page you want as your main default, which you don't want to do. That feature is intended to show a special 404 error message page as opposed to the default error you originally saw.

      You may name your Template file, and the Template itself whatever you like. These are made and maintained in the Templates node of the Settings section. I used the additional tern Masterpage, because the template documents take the form of ASP.NET masterpages.

      In the Content section, the first node in the tree (under 'Content') is what umbraco will treat as your default.aspx (like default.html or index.html), so it is important that you Sort the Content via right click option to get your Default content page to the top. If you are adopting an umbraco site, you likely will not see menus until you add more content. Most umbraco sites use Xslt to examine the site structure and create menus dynamically--if there is no content there is no menu.

    Get a content page of the Document Type that employs your main default template to the top of the Content tree. Add other content pages, hopefully, to your actual frontpage in the content tree (you'll need to OK children in the STructure tab of Document Types in Settings).

    good luck!

  • Anita Thagaard Kristensen 33 posts 53 karma points
    Aug 27, 2010 @ 17:32
    Anita Thagaard Kristensen
    0

    Hi xander

    I got it to work. Stupid little me, I forgot that I had to make the sub content before the last menu can work.

    So the help I got from you worked. Thanks a lot.

    Regards Anita

  • Anita Thagaard Kristensen 33 posts 53 karma points
    Aug 27, 2010 @ 17:47
    Anita Thagaard Kristensen
    0

    Hi xander

    But I can only get it to work if I keep the change in config/umbracoSettings.config. I tried to do as you mentioned above by sorting the content, but that didn't helped. I drag and drop it under sort but I still got the special 404 error.

    What do I do wrong??

    Anita

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

    The solution above with the GetXmlNodeById is nice, but I think there is even a better solution:

    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/field)" disable-output-escaping="yes"/> ) to render Template2.

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

     

Please Sign in or register to post replies

Write your reply to:

Draft