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.
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
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.
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.
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)
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!
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.
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
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.
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!
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.
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.
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.
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
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
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
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
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
You could create variables for each content value you want to use
Remember to change the id of the masterContentPage.
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
Do you mean a syntax error in the xslt? or that it always chooses the 'when' condition?
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>
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
xsl:when test=""
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
Change
to
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.
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
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 " "> ]>
<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
Looks like it should work.
Does the welsh bodyText have a value in it? Try outputting the string length just to check.
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.
yep... it's just a test line to 100% confirm there is no value in the bodyText.
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
sure... chris __{at}__ g mail
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
sorry... it should have been chriskoiak __{at}__ g mail
is working on a reply...