Change icon in Browse repeater based on Child template type.

Alan Isaacson asked on March 9, 2016 16:45

I am currently trying to implement a browse repeater to show related pages with a customer icon based on page type.

I currently have

    <li class="dropdown">
  {% if (NodeHasChildren){ %}
    <a class="dropdown-toggle" aria-expanded="false" aria-haspopup="true" href="{% GetDocumentUrl() %}" role="button" data-toggle="dropdown">
  {% }else{ %}
    <a href="{% GetDocumentUrl() %}" role="button">
  {% } #%}
      <span data-icon="{% MenuItemIcon %}" aria-hidden="true"></span>
      <span>{% DocumentName %}</span>


What I would like to do is say if the template of the child page is illustration then use data icon x, if it template factsheet then use data icon y. I have a collection of about 6 different icons to use. Any help appreciated, unfortunately I don't get to play with macros as much as I would like.

Correct Answer

Jan Hermann answered on March 9, 2016 21:43


I am not sure about your description, but if you want to display some icon according to a page type of a child page of a page you list in your repeater the macro could look like this:


Best regards,
Jan Hermann

0 votesVote for this answer Unmark Correct answer

Recent Answers

emma zelewsky answered on March 9, 2016 23:14 (last edited on December 10, 2019 02:30)

Another approach would be to add a thumbnail to each of your six templates and call the thumbnail image. That would give you flexibility if you add templates or change your icons down the road.

To add a thumbnail, go to Page Templates --> your template --> General tab --> Thumbnail [image] --> upload.

Then the transformation can grab the thumbnail image like so-- <img src="~/CMSPages/GetMetaFile.aspx?fileguid={% DocumentContext.CurrentDocument.DocumentNode.Children.All[0].NodeTemplate.Thumbnail.GUID |(identity)GlobalAdministrator%}"/>

And in case you haven't found it yet, one of my faves is the handy macro utility under System --> Macros --> Console that can help build and test macros (with real or virtual data).

Good luck!

0 votesVote for this answer Mark as a Correct answer

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