Forum

Thread tagged as: Question

perch navigation with custom sublink

I want to create some custom sub menu navigation (dynamically). but I don't want to modify level1.html file every time I want to add.

How can i supply sub menu <li> tag or print variable from session.

any help please?

sawan ruparel

sawan ruparel 0 points

  • 5 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

I don't understand the question. Can you show us what you are trying to do including your code please?

This is how my level1.html looks like

  <perch:before>
    <ul class="top-bar-section-primary">
</perch:before>
    <perch:if id="pageNavText" match="eq" value="Fashion">
        <li class="primary has-dropdown fashion"><a href="#"><perch:pages id="pageNavText" /></a>   
                <ul class="dropdown">
                    <li><a title="Spring 2016" href="/<perch:if exists="lang"><perch:pages id="lang" />/</perch:if>collections/spring-2016">Spring 2016</a></li>
                    <li><a title="Bridal 2016" href="/<perch:if exists="lang"><perch:pages id="lang" />/</perch:if>collections/bridal-2016">Bridal 2016</a></li>
                    <li><a title="Bridal 2016" href="/<perch:if exists="lang"><perch:pages id="lang" />/</perch:if>collections/fall-2016">Fall 2016</a></li>
                </ul>
    <perch:else />
        <li class="primary has-dropdown fashion"><a href="<perch:if exists="lang">/<perch:pages id="lang" /></perch:if><perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a>   
    </perch:if>
    <perch:pages id="subitems" encode="false" /></li>
<perch:after>
<li class="primary sticky-bag has-cart open">
                    <a href="/cart/" class=""><i class="fa fa-shopping-bag"></i></a>
                </li>
                <li class="primary sticky-search search  has-cart open">
                    <a href="javascript:void(0)">
                        <i class="sherri-search-icon">&nbsp;</i>
                    </a>
                </li>
    </ul>
</perch:after>

I want to Spring 2016 <li> part to be dynamic, right now I have it as static

Drew McLellan

Drew McLellan 2638 points
Perch Support

You could pass it into the template from the page. In the page you could source it from a content region.

https://docs.grabaperch.com/docs/templates/passing-variables-into-templates/

Drew,

I did pass using that link, but the HTML does not render well.

I am not sure what you mean by "In the page you could source it from a content region". ?

Drew McLellan

Drew McLellan 2638 points
Perch Support

What do you mean by "the HTML does not render well" ?

"the HTML does not render well" means "it converts HTML into encoded so < converts to " or something similar for all html tags.

if there was a way to display "raw" variable, that would be perfect

Drew McLellan

Drew McLellan 2638 points
Perch Support

Add encode="false".

that is exact magical piece of code I was looking for.

Thanks Drew