Multilingual Submenu
This is an open discussion with 7 replies, filed under Troubleshooting.
Search
Your template match
is on entry
. And you apply the last template on page
.
Make your template match
less specific:
<xsl:template match="//*" mode="path">
Thank you for your answer. I have changed the template match in "//*" as you suggested but I am sure I haven't followed your advice correctly. I report below all my language.xsl to understand better what I have to modify. All the pages must follow the "plh-page/page" template with the exception of the "symphony/en/products/view-page" subpage called "page" which foollow the "page-entry/entry" template.
<xsl:template match="supported-languages" mode="languages"> <ul id="nav"> <xsl:apply-templates select="item"/> </ul> </xsl:template> <xsl:template match="supported-languages/item"> <xsl:param name="language" select="@handle"/> <li> <a> <xsl:attribute name="href"> <xsl:value-of select="$root"/> <xsl:text>/</xsl:text> <xsl:value-of select="@handle"/> <xsl:text>/</xsl:text> <xsl:apply-templates select="/data/plh-page/page" mode="path"> <xsl:with-param name="language" select="$language"/> </xsl:apply-templates> <xsl:apply-templates select="/data/page-entry/entry" mode="path"> <xsl:with-param name="language" select="$language"/> </xsl:apply-templates>--> </xsl:attribute> <xsl:if test="@handle = $current-language/@handle"> <xsl:attribute name="class">current</xsl:attribute> </xsl:if> <xsl:value-of select="@handle"/> </a> </li> </xsl:template> <xsl:template match="page" mode="path"> <xsl:param name="language"/> <xsl:value-of select="item[@lang = $language]/@handle"/> <xsl:text>/</xsl:text> <xsl:apply-templates select="page" mode="path"> <xsl:with-param name="language" select="$language"/> </xsl:apply-templates> </xsl:template> <xsl:template match="data/page-entry/entry" mode="path"> <xsl:param name="language"/> <xsl:choose> <xsl:when test="$language = 'en'"> <xsl:value-of select="title/@handle-en"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="title/@handle-it"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
When I look at your template I noticed two things:
Before the first closing </xsl:attribute>
there are remainings from a comment (-->
)
But I think it goes wrong here:
<xsl:template match="page" mode="path"> <xsl:param name="language"/> <xsl:value-of select="item[@lang = $language]/@handle"/> <xsl:text>/</xsl:text> <xsl:apply-templates select="page" mode="path"> <xsl:with-param name="language" select="$language"/> </xsl:apply-templates> </xsl:template>
The apply template points to page again and I guess you like to select the entry there?
Thank you again plenaforma! Not exactly, I would like to select the match="page" template on a page (view-page) that includes a list of links from an "entry" template.
It seems that as a data entry template is associated to that page (view-page), the page desn't follow the "plh-page" template as I would like it to do.
I would like to write something like "if the page is view-page follow "plh-page" template".
enrico
I would like to write something like "if the page is view-page follow "plh-page" template".
Something like:
<xsl:if test="view-page"> <!-- CHECK here if a node exist --> <xsl:apply-templates select="what-you-like" mode="a-mode" /> </xsl:if>
I really thank you for your support. I was able to solve this issue writing this code:
<xsl:template match="page-entry/entry" mode="path"> <xsl:param name="language"/> <xsl:choose> <xsl:when test="$current-page = 'view-page'"> <xsl:apply-templates select="page/item" mode="path"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="page-entry/entry"mode="path"/> <xsl:choose> <xsl:when test="$language = 'en'"> <xsl:value-of select="title/@handle-en"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="title/@handle-it"/> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:template>
You're welcome. And you're code looks good.
XSL and Xpath got sometimes a steep path to learn or to understand what happens.
Create an account or sign in to comment.
Hello, I'm new on symphony. I have got an issue about multilingual sub-menu and I will try to explain this problem as clear as possible.
I have realised a submenu for one main menu's entry. The submenu holds two pages. In these pages there is a list of titles and links that send you to the related contents. I have realized this part following the tutorial example, so using the {$title} parameter to call one content at ones from a page marked as hidden. So every content called by title parameter as a address like:symphony/en/products/view-page/page/product-one
To allow the translation of these contents I have added to my languages.xsl file the following code:
This code works properly on: "symphony/en/products/view-page/page/product-one" page but when I go to "symphony/en/products/view-page" the language manu add to the link all the title's handles present inside the "page-entry". I would like this page to follow this code:
How I can solve this issue? Hope to have been enough clear. enrico