Developer forum

Forum » Templates » Current product in breadcrumb

Current product in breadcrumb

Nikki Strømsnes
Reply

I have a product page with an XSLT breadcrumb, which works fine when you travel down the eCom structure.

For example: Home » Products » Doomsday weapons

 

However, as soon as I go to a specific product, it stops, and instead I simply get the path to the product page.

Home » Products

 

Of course, I would like to display the product in the breadcrumb, even if I can't give the full path. For example:

Home » Products » 8000 GW Plasma Artillery Deluxe Edition
 

 

I can't seem to get any output for the product in the XML.

I've tried to toggle the "Show on paragraph" option, but to no avail.

I've also tried to toggle the "Product page" in the navigation settings.

It's set to show max levels.

 

Here's my XSLT:

	<xsl:template match="/NavigationTree">

		<xsl:if test="count(//Page) > 0">
			<li><a href="/">Forside<span></span></a></li>
			<xsl:apply-templates select="//Page[@InPath='True']">
				<xsl:with-param name="depth" select="1"/>
			</xsl:apply-templates>
		</xsl:if>

	</xsl:template>

	<xsl:template match="//Page[@InPath='True']">
		<xsl:param name="depth"/>
			<li>
				<a>
					<xsl:if test="@Allowclick='True'">
						<xsl:attribute name="href"><xsl:value-of select="@FriendlyHref" disable-output-escaping="yes"/></xsl:attribute>
		        </xsl:if>

				<xsl:value-of select="@MenuText" disable-output-escaping="yes"/>
			</a>
		</li>
	</xsl:template>

 

 

What am I doing wrong?

 

 


Replies

 
Nikki Strømsnes
Reply

 To clarify: I can get the path for the product page and all underlying product groups, as I click through them. When I click on a specific product, I don't get the product title in the breadcrumb as expected, but just the path for the product page.

 
 
Jacob Bertelsen
Reply

We meet again, Nikki.

It seems I have the same problem as Nikki describes above.

Anybody got a solution for this?

 
Morten Bengtson
Reply
This post has been marked as an answer

Hi,

 

If I understand you correct, what you need is a breadcrumb path including the current product as seen on the solution set demo site.

The trick is to append an extra item to the breadcrumb inside the layout template when a product id is in the request:

<ul class="breadcrumb">
    <li id="NavBreadcrumb" class="dwnavigation" data-settings="template:breadcrumb.xslt;expandmode:pathonly;">
        <a href="#">Home</a> <span class="divider sprite arr-forward-small"></span>
    </li>
    <!--@If Defined(Server:Request.productid)-->
    <li class="active">
        <!--@Title-->
    </li>
    <!--@EndIf(Server:Request.productid)-->
</ul>

Also, notice that the dwnavigation class is not on the ul, but on the first li in the list.

 

I have attached the breadcrumb.xslt from solution set.

 

You can download the complete solution set from the download section.

Votes for this answer: 1
 
Jacob Bertelsen
Reply

Hi Morten,

Thank you for your response :) .

This seems to be what I need. I will get back, when I have had the time to implement this, on the specific solution.

 

Thanks again :)

 
Adrian Ursu
Reply

I have recently stumbled upon the same problem. 

Thanks for your solution.

I would have appreciated however, that DW would provide an out-of-the-box solution without having to improvise that much.

Nevertheless, your solution works, and that's important.

Thanks,

Adrian

 

You must be logged in to post in the forum