Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-04-05 17:12:38

funtoosh
Member
From: Münster, Germany
Registered: 2006-10-09
Posts: 153
Website

Creating section navigation with active/populated sections only

Hey there,
I am pretty sure I have done this before, and found advice on this right over here before, but I can’t for the life of me remember how to, soo:

How can I tell a section navigation to show only those sections that are currently in use?
(Especially handy for multilingual sites w/ MLP, obviously)

Anyone??

Cheers,
-f

Last edited by funtoosh (2018-04-05 17:18:15)

Offline

#2 2018-04-05 17:46:29

etc
Developer
Registered: 2010-11-11
Posts: 5,062
Website GitHub

Re: Creating section navigation with active/populated sections only

Hey, something like this (alter wraptag as needed):

<txp:section_list wraptag="ul">
    <txp:article_custom section='<txp:section />' limit="1" wraptag="li">
        <txp:section link="1" title="1" />
    </txp:article_custom>
</txp:section_list>

Offline

#3 2018-04-05 17:53:49

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,028
Website GitHub Mastodon Twitter

Re: Creating section navigation with active/populated sections only

Hi, you can try the untested code below:

<ul id="menu">
<li><a rel="home" href="<txp:site_url />"><txp:site_name /></a></li>
<txp:section_list break="li">
<txp:variable name="hasarticles" value='<txp:article_custom section='<txp:section />' break="" wraptag="" limit="1" />'>
<txp:if_variable name="hasarticles" value="">
<txp:else />
<txp:section title="1" link="1" />
</txp:if_variable>
</txp:section_list>
</ul>

>Edit: Oleg beat me to it with what looks like a more economical combination.

Last edited by colak (2018-04-05 17:55:51)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2018-04-05 18:00:10

etc
Developer
Registered: 2010-11-11
Posts: 5,062
Website GitHub

Re: Creating section navigation with active/populated sections only

colak wrote #310675:

Oleg beat me to it with what looks like a more economical combination.

The idea is the same, you just don’t need to store the “test” article.

Offline

#5 2018-04-13 10:51:37

funtoosh
Member
From: Münster, Germany
Registered: 2006-10-09
Posts: 153
Website

Re: Creating section navigation with active/populated sections only

Hey, thanx a lot! Simplicitity rules .-)

Offline

Board footer

Powered by FluxBB