Breadcrumb with repeater

Zbyněk Nedoma asked on September 18, 2018 11:52

Hi my question is about creating Breadcrumb with repeater. How do I say Path that I want to select current page and all parrents up to Master Page? I was trying combinations of ".", "..", "/%" from this page, but it is not working.

Please can you help me?

Thanks, Zbynek

Correct Answer

Zbyněk Nedoma answered on September 19, 2018 15:17

Hi, thanks for answer. For now I wrote it like this and it is working

{% for (i = 1; i < CurrentDocument.DocumentsOnPath.Count; i++) { %}
  <li>
    {% if (i < CurrentDocument.DocumentsOnPath.Count - 1) {  %}
        <a href="{% CurrentDocument.DocumentsOnPath[i].NodeAliasPath %}">{% CurrentDocument.DocumentsOnPath[i].DocumentName %}</a>
    {% } else { %}
        <span>{% CurrentDocument.DocumentsOnPath[i].DocumentName %}</span>
    {% } %}
  </li>
{% }  |(identity)GlobalAdministrator%}
0 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on September 18, 2018 12:52 (last edited on September 18, 2018 13:13)

did you try /? Is there a reason why you don't want to use the existing web part, I mean breadcrubms webpart?

0 votesVote for this answer Mark as a Correct answer

Zbyněk Nedoma answered on September 18, 2018 12:55 (last edited on September 18, 2018 12:55)

Yes I tried, but it selected nothing (it has no result).

0 votesVote for this answer Mark as a Correct answer

Zbyněk Nedoma answered on September 18, 2018 13:00

I don't want to use Breadcrumb web part because I am not able to change transformations for elements

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on September 18, 2018 18:29 (last edited on September 18, 2018 18:41)

in \CMS\CMSWebParts\Navigation\cmsbreadcrumbs.ascx.cs - it calls MacroResolver.ResolveCurrentPath(value) on StartPath property. I dont know if it does the same in a regular repeater. Check the query produced by repeater. May be there are some query conditions that affect the result. ACtually there is already a topic on devnet

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on September 18, 2018 18:55 (last edited on December 10, 2019 02:31)

Technically you can do it like this: {%CurrentDocument.DocumentsOnPath.Transform("<a href='{#AbsoluteURL#}'>{#DocumentName#}</a> \ ")|(identity)GlobalAdministrator%} or use ApplyTransformation if you dont want to use inline one.

0 votesVote for this answer Mark as a Correct answer

Zbyněk Nedoma answered on September 19, 2018 09:54

Peter, thank you for helping, but really what I need is a way how to define Path so I receive parents up to master. Your code is functional, but lacks options for better transformations that I need.

Any help about the Path to mater?

Thanks, Zbynek

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on September 19, 2018 15:02 (last edited on December 10, 2019 02:31)

So not sure a repeater is the correct way, but if you need it's current flexibility you might want to select you complete tree in path

/%

BUT exclude all non-relevant pages by using the where condition to compare it's NodeAliasPath with your current page.

So all parent pages of Jobs/Europe/Netherlands should have a NodeAliasPath that is the partially the current full path.

JOBS and JOBS/EUROPE

So your where condition can be something as {%CurrentDocument.NodeAliasPath|(identity)GlobalAdministrator%} like NodeAliasPath + '%'

-- Don't have my test environment at hand, so may need some tweaking on the last Column + '%' syntax

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.