Copied to clipboard

Flag this post as spam?

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


  • Matthew Jarvis 129 posts 129 karma points
    Oct 27, 2009 @ 12:17
    Matthew Jarvis
    1

    Action handler to update related node

    Hi,

    I have successfully implemented an action handler (after consultation with a developer on a very large unnamed Umbraco site) that automatically creates a page within a related folder when a new page is created e.g my welsh version folder of site is a related copy of original to my english version.  Whenever an extra page is added to my english site, the same page is replicated within my welsh version. 

    What I am now after, is has anyone created an action handler so that when content is updated within a certain page that any related pages are also updated with this same content.  For example, content within an about us page located on the english version of the site automatically pushes the same content to all related about us pages in the Welsh, German etc versions of the site.

    If someone could provide a solution to this I would be most grateful as currently in my working site using V3 (have a test V4 for the above) I have to edit 2 language versions of a page whenever needed which can cause a real annoyance and I can sometimes forget to edit the 2nd language version!

    FYI - I have 2 language version of the site - English and Welsh, All body content is in English with the only difference on welsh language pages being the navigation items.

    Many Thanks

    Matt

  • Chris Koiak 700 posts 2626 karma points
    Oct 27, 2009 @ 14:20
    Chris Koiak
    0

    Would you really want to push English content into a Welsh site? Is it automatically translated on push?

    If it's identical content, I would recommend storing this content centrally and reading it out via xslt on the applicable templates.

    Think about restructuring the templates and xslt of your Welsh site before you copy content.

    Cheers,

    Chris

  • Matthew Jarvis 129 posts 129 karma points
    Oct 27, 2009 @ 15:15
    Matthew Jarvis
    0

    Hi Chris,

    It does seem a bit odd having english content within a welsh version of a site but we are an educational establishment and as the majority of our courses are taught in English that is the agreement we currently have with our government (this is something that will remain for the foreseable future). 

    Content is not automatically translated due to insufficent machine translation support for welsh language together with inaccacurcies they bring. No in house translator is employed and unlikely to be where content could be sent for translation.

    It is identical content that will be in both so implementing what you've suggested makes since - holding say "about us" text somewhere and having en/about-us.aspx and cy/about-us.aspx access this information to display within their page.  Which leads nicely on to where would I begin to start this? :-)

    Current structure is

    Home (english)

     Some english pages

     Some pages

    Hafan (welsh)

     some welsh pages

     some welsh pages

    I may assign a hostname to the welsh version so that instead of being named hafan (which is welsh for home) it will be www.ystrad-mynach.ac.uk/cy/home.aspx

     

     

  • Chris Koiak 700 posts 2626 karma points
    Oct 27, 2009 @ 18:47
    Chris Koiak
    0

    There's lots of ways to acheive this..

    Option 1 (fairly generic approach)

    1) Create a content picker on each page, called 'master content'.

    2) When your xslt's are outputting content then first check if a 'master content' page exists. If it does (and the content field on the current page hasn't got a value) then read the master content value.

    This should allow you to override any content item on any page with the 'master content'.

    Option 2 (more fixed)

    Create a third tree structure called 'Shared Content'. In this area put all the pages that will have shared content.

    You will still need to create pages in each website (e.g. About Us), but the xslt will not read the content from the current page, instead it will go to the shared content section.

    You will probably need to define the page id's of each shared content page in the xslt's for this approach.

    I hope this makes sense.

    Chris

  • Matthew Jarvis 129 posts 129 karma points
    Oct 29, 2009 @ 11:32
    Matthew Jarvis
    0

    Hi Chris,

    Thanks for your reply, i think Option 1 sounds the most appealing to me.  My xslt skills however are pretty basic, certainly not at the level of creating one from scratch to do the above.  I've tried looking on this and the "old" forum for something similar but have seen no other posts.

    Going out to the Umbraco community - If anybody has done anything similar to the above and can provide any code that'd be fantastic.

    Many Thanks

    Matt

  • Chris Koiak 700 posts 2626 karma points
    Oct 29, 2009 @ 14:34
    Chris Koiak
    0

    You could create variables for each content value you want to use

    <xsl:variable name="masterContentPage" select="$currentPage/ancestor-or-self::root//node[@id=1234]">

    <xsl:variable name="contactUsText">
    <xsl:choose>
    <xsl:when select="string-length($currentPage/data[@alias='contactUsText']) > 0">
    <xsl:value-of select="$currentPage/data[@alias='contactUsText']"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$masterContentPage/data[@alias='contactUsText']"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>

    Remember to change the id of the masterContentPage.

  • Matthew Jarvis 129 posts 129 karma points
    Oct 29, 2009 @ 16:16
    Matthew Jarvis
    0

    Thanks for getting back have tried the following using your info adapting to my system

    <xsl:variable name="masterContentPage" select="$currentPage/ancestor-or-self::root//node[@id=1276]">

    <xsl:variable name="coursesText">
       <xsl:choose>
          <xsl:when select="string-length($currentPage/data[@alias='coursesText']) > 0">
                <xsl:value-of select="$currentPage/data[@alias='coursesText']"/>
          </xsl:when>
          <xsl:otherwise>
                <xsl:value-of select="$masterContentPage/data[@alias='contactUsText']"/>
          </xsl:otherwise>
       </xsl:choose>
    </xsl:variable>
    </xsl:variable>

    All the above sitting within the template and stylesheet xsl tags. 

    I have on the first line changed the node id 1276 which matches the id of a page titled courses.  I am getting an error however on the line   <xsl:when select="string-length($currentPage/data[@alias='coursesText']) > 0"> pulling up an area on the character between the when and select (have tried placing a "-" in between no luck) 

    Cheers

     

  • Chris Koiak 700 posts 2626 karma points
    Oct 29, 2009 @ 17:29
    Chris Koiak
    0

    Do you mean a syntax error in the xslt? or that it always chooses the 'when' condition?

  • Matthew Jarvis 129 posts 129 karma points
    Oct 30, 2009 @ 10:27
    Matthew Jarvis
    0

    Syntax error

    Error in XSLT at line 21, char 17
    19:      <xsl:variable name="coursesText">
    20:       <xsl:choose>
    21: >>>   <xsl:when select="string-length($currentPage/data[@alias='coursesText']) > 0"> <<<
    22:       <xsl:value-of select="$currentPage/data[@alias='coursesText']"/>
    23:       </xsl:when>

     


  • Chris Koiak 700 posts 2626 karma points
    Oct 30, 2009 @ 10:47
    Chris Koiak
    0

    just try retyping the line yourself. It's probably using the longer hyphen rather than the shorter one (don't know the exact terms)

    Chris

  • skiltz 501 posts 701 karma points
    Oct 30, 2009 @ 10:48
    skiltz
    1

    xsl:when test=""

  • Matthew Jarvis 129 posts 129 karma points
    Oct 30, 2009 @ 15:39
    Matthew Jarvis
    0

    Chris - Tried retyping and error still appears

     

    Skilltz - changed the when select to when text and get the following

    Error Occured

    System.Xml.Xsl.XslLoadException: The variable or parameter 'masterContentPage' cannot have both a 'select' attribute and non-empty content. An error occurred at C:\inetpub\wwwroot\xslt\633925103944774055_temp.xslt(30,1).
    at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
    at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

    Unfortunately in 1 hours time i'll be away for 12 days so think i'll be getting my head around this when I return!

    Any further help much appreciated

  • Chris Koiak 700 posts 2626 karma points
    Oct 30, 2009 @ 16:10
    Chris Koiak
    0

    Change

    <xsl:variable name="masterContentPage" select="$currentPage/ancestor-or-self::root//node[@id=1276]">

    to

    <xsl:variable name="masterContentPage" select="$currentPage/ancestor-or-self::root//node[@id=1276]" />
  • Matthew Jarvis 129 posts 129 karma points
    Oct 30, 2009 @ 16:40
    Matthew Jarvis
    0

    Hi Chris,

    Great that now works.  In terms of implementing it am i right in saying that I need to create xslt's like this one above for every content page now then and make a call for the xslt within my templates.

    When i create a copy then of say about us page within my other language site, the xslt searches first to see if i have added any body text.  If I have it does not copy any english text over.  If i haven't it does copy over the english text.

  • Matthew Jarvis 129 posts 129 karma points
    Nov 16, 2009 @ 15:13
    Matthew Jarvis
    0

    Hi Chris,

    Just returned from leave and now getting chance to crack on with the above.  The XSLT validates in that no error messages are appearing within umbraco but

  • Matthew Jarvis 129 posts 129 karma points
    Nov 16, 2009 @ 15:21
    Matthew Jarvis
    0

    pressed submit by mistake

    Hi Chris,

    Just returned from leave and now getting chance to crack on with the above.  The XSLT validates in that no error messages are appearing within umbraco but cannot get what the XSLT should be doing to work.

    My code as follows

    <code>

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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:template match="/">

    <xsl:variable name="masterContentPage" select="$currentPage/ancestor-or-self::root//node[@id=1276]" />

    <xsl:variable name="coursesText">
       <xsl:choose>
          <xsl:when test="string-length($currentPage/data[@alias='bodyText']) > 0">
                <xsl:value-of select="$currentPage/data[@alias='bodyText']"/>
          </xsl:when>
          <xsl:otherwise>
                <xsl:value-of select="$masterContentPage/data[@alias='bodyText']"/>
          </xsl:otherwise>
       </xsl:choose>
    </xsl:variable>


    </xsl:template>

    </xsl:stylesheet>

    </code>

    My site structure as follows

    Content

      English

           Courses (refrenced by 1276 in the XSLT above

      Welsh

           Courses

    The above macro has been placed within the welsh template so when the bodyText in english course page is updated was hoping that the above macro would kick in and check whether any content already exists within the welsh courses bodyText, if not the english courses bodyText data is copied across.

    Am I missing anything else that I need to be doing.  The end looks as if its almost in sight - hopefully!

    Cheers

    Matt

     

     

     

     

     

     

  • Chris Koiak 700 posts 2626 karma points
    Nov 17, 2009 @ 14:39
    Chris Koiak
    0

    Looks like it should work.

    Does the welsh bodyText have a value in it?  Try outputting the string length just to check.

     <xsl:value-of select="string-length($currentPage/data[@alias='bodyText'])"/>

     

  • Matthew Jarvis 129 posts 129 karma points
    Nov 17, 2009 @ 16:05
    Matthew Jarvis
    0

    No values are within the welsh bodyText. Where you said to try outputting the string length (via the line of code you provided) should this line of code go within the original xslt shown above.

  • Chris Koiak 700 posts 2626 karma points
    Nov 17, 2009 @ 19:31
    Chris Koiak
    0

    yep... it's just a test line to 100% confirm there is no value in the bodyText.

  • Matthew Jarvis 129 posts 129 karma points
    Nov 18, 2009 @ 13:00
    Matthew Jarvis
    0

    Hi Chris,

    Still unable to get it working. Its proberly really close to happening and I guess something i've done somewhere.  Would it be possible to have your email address and if you did have some spare time I could be able to provide access to our test system for you to have a look.  No worries if this is not possible understand that providing support like this is certainly not within your day to day job description.

    Mnay thanks

    Matt

  • Chris Koiak 700 posts 2626 karma points
    Nov 18, 2009 @ 13:17
    Chris Koiak
    0

    sure... chris __{at}__ g mail

  • Matthew Jarvis 129 posts 129 karma points
    Nov 18, 2009 @ 15:02
    Matthew Jarvis
    0

    Great,

    Have just sent you an email, havent included any details in case i got the wrong address. If you could reply to the mail when you get it and I can sort out details for you.

    Cheers

  • Chris Koiak 700 posts 2626 karma points
    Nov 18, 2009 @ 15:53
    Chris Koiak
    0

    sorry... it should have been chriskoiak __{at}__ g mail

Please Sign in or register to post replies

Write your reply to:

Draft