given Child page how do i get the Parent page?
This is an open discussion with 8 replies, filed under General.
Search
You could create a (named) template (utility) that recursively creates this link for you, based on the Navigation DS output. That's basically the exact opposite of the other recursive navigation utilities you'll find here...
hi @ all
it should work like that right?
<xsl:template match="kategorie"> <ul> <xsl:apply-templates select="entry" /> </ul> </xsl:template> <xsl:template match="kategorie/entry"> <li> <xsl:value-of select="titel" /> <xsl:apply-templates select="../../kategorie[@link-id = current()/@id]" /> </li> </xsl:template> <xsl:apply-templates select="kategorie[@link-id='']" />
Thats a recursive thing i think...
Can you please post some XML to see how it looks like?
Hi vladG
This a paste of my Nav DS and this is the search output
Now all the Pages given are Child pages and the parent Pages are in the Nav DS... i hope my explanation is ok...
i had tested the whole evening but what i found out that i can merge with "concat". now i should search the child page which is given in the search result in the ds-navigation
and then i should give out the parent page.
but no idea how can i do this...
Ok, I created a test page for this stuff in a local Symphony install. It outputs links like this:
1_ For each search entry, do some stuff:
<xsl:template match="data"> <xsl:apply-templates select="search/entry" /> </xsl:template>
2_ Output a link:
<xsl:template match="search/entry"> <a> <xsl:attribute name="href"> <xsl:value-of select="/data/params/root" /> <xsl:apply-templates select="/data/ds-navigation//page[@id = current()/seite-de/page[1]/@id]" mode="search-url" /> </xsl:attribute> <xsl:value-of select="concat('entry@id=', @id, ' in ', @section)" /> </a> <br /> </xsl:template>
In this template I used the //
operator. This xPath syntax /data/ds-navigation//page
selects ALL nodes named page
from /data/ds-navigation
. Check it in ?debug
.
In this case I want to select only a specific page, so I match the @id
attribute with the page from search result: page[@id = current()/seite-de/page[1]/@id]
.
3_ Next, for each page node, I apply a recursive template with mode="search-url"
to avoid confusion. First call the template for every parent page, next output the handle.
<xsl:template match="page" mode="search-url"> <xsl:apply-templates select="parent::page" mode="search-url" /> <xsl:value-of select="concat('/', @handle)" /> </xsl:template>
You will need to adapt this to your implementation, but it's a working concept.
Thanks vladG works well!
Glad to hear that.
Create an account or sign in to comment.
Hi @ all.
I have a Search result Page with results from the Search Index Extension. Now in the results are the Child-Pages but i should create links to the original Articels. And now I don't know how i can give out the parent Pages. I have only nested Pages and nothing else...
any Idea?
thanks for help!