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
    Jun 20, 2011 @ 17:47
    Matthew Jarvis
    0

    Pushing Content Automatically to Related Nodes

    Hi,

    Currently running 4.7.0. About to launch a multilingual site supporting English and Welsh (in parts!).

    My site will be slightly different to other multilingual sites in that bodyText content will always be in English unless told otherwise. The welsh version of the site simply has a Welsh template which includes Welsh Navigation but the bodyText area will still be in English unless told otherwise.

    I have implemented a RelatedCopyonCreation class (thanks to Relations Demo source files from Umbraco.TV) so that when a page is created in my English site it is also duplicated into the Welsh Site.

    I plan to add a content picker on each Welsh page on my site.  This content picker will be used to select its English counterpart.

    Has anyone had any experience of the creation of a macro which does this:-

    First check if content exists in a bodyText field (in this instance Welsh)

    If it does then display this bodyText (in this example Welsh) else show someotherbodyText (in this example it's English Equivalent which will be defined from the content picker)

    So basically for 90% of the Welsh site, English text will appear which will be taken from its English related page.  In the odd occassion that a Welsh page needs a unique bodyText content, this will be displayed instead.

    If anyone has experienced this before and is able to provide help it would be much appreciated.

    Many Thanks

    Matt

     

     

  • Matthew Jarvis 129 posts 129 karma points
    Jun 23, 2011 @ 17:51
    Matthew Jarvis
    0

    Intentional bump ;-)

  • Matthew Jarvis 129 posts 129 karma points
    Jul 07, 2011 @ 16:55
    Matthew Jarvis
    0

    Hate doing this but intentiional bump number 2 ;-)

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    Jul 07, 2011 @ 17:13
    Sebastiaan Janssen
    0

    Strange that you haven't had an answer yet! Are you using XSLT or Razor?

    In both cases this will be easy to do, here's an XSLT examle, off the top of my head:

    <xsl:choose>
      <xsl:when test="$currentPage/bodyText = ''">
        <xsl:value-of select="umbraco.library:GetXmlNodeById($currentPage/altContentPicker)/bodyText" disable-output-escaping="yes" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$currentPage/bodyText" disable-output-escaping="yes" />
      </xsl:otherwise>
    </xsl:choose> 
  • Matthew Jarvis 129 posts 129 karma points
    Jul 08, 2011 @ 10:44
    Matthew Jarvis
    0

    Have implemented your code and it's looking very close to working.  . 

    The english version of a page is showing content correctly, at the moment the Welsh version (if its bodytext is left blank) is not displaying its english counterpart

    My content picker has an alias of @englishpage - not sure if this needs to be implemented somewhere in the code you provided, please could you advise

    This is what i've got so far:-

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

    <xsl:param name="currentPage"/>
    <xsl:param name="dataAlias" select="macro/dataAlias"/>

    <xsl:template match="/">

    <xsl:choose>
      <xsl:when test="$currentPage/bodyText = ''">
        <xsl:value-of select="umbraco.library:GetXmlNodeById($currentPage/altContentPicker)/bodyText" disable-output-escaping="yes" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$currentPage/bodyText" disable-output-escaping="yes" />
      </xsl:otherwise>
    </xsl:choose>     

    </xsl:template>

    </xsl:stylesheet>   

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    Jul 08, 2011 @ 11:01
    Sebastiaan Janssen
    0

    Yup, change altContentPicker to englishpage and you should be good to go!

  • Matthew Jarvis 129 posts 129 karma points
    Jul 08, 2011 @ 11:17
    Matthew Jarvis
    0

    Seb - you've just made my Friday, weekend and next few weeks great!  Thank you ever so much, works fantastic, Time to start dancing now around the office :-)

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    Jul 08, 2011 @ 11:19
    Sebastiaan Janssen
    0

    Happy to help, make sure to mark an answer as correct before you start dancing though. ;-) never mind, already done  I see! ;)

Please Sign in or register to post replies

Write your reply to:

Draft