Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2022-09-02 22:10:17

NorfolkGreg
Member
From: Norfolk Broads, UK
Registered: 2022-07-07
Posts: 13

Sorting the Section List/Main Menu

It seems that as I create Sections the Names appear in alphabetical order on the Sections page. That’s fair enough. However, they then appear in the same order on my site’s main menu. That’s not what I want, as I want to use the “section/title” URL pattern but don’t want the menu in alphabetical order.

Yes, I know I can create Titles that are different to the Names but I can’t come up with enough synonyms to satisfy me.

Have I missed something? Is there another/better way to place main menu options in the order I want?

Offline

#2 2022-09-03 01:44:59

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,162
Website

Re: Sorting the Section List/Main Menu

There is the sort attribute on the <txp:section_list /> tag that might help. I prefer building a menu more manually to get the exact order desired.

<nav><ul>
  <li><txp:section name="section1" title="1" link="1" />
  <li><txp:section name="section3" title="1" link="1" />
</ul></nav>

that requires some manual intervention every time you add or delete an section, though.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#3 2022-09-03 05:59:44

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,162
Website

Re: Sorting the Section List/Main Menu

Something I had totally forgotten: you can also sort manually by using the sections="section name(s)" on the <txp:section_list />.

<txp:section_list sections="section_3, other_section, section_1" />

You still need to edit the list every time you add or delete a section, though.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#4 2022-09-03 07:13:35

NorfolkGreg
Member
From: Norfolk Broads, UK
Registered: 2022-07-07
Posts: 13

Re: Sorting the Section List/Main Menu

Thanks phiw13!

That provided the clues I needed. I have now worked out that you are saying that I need to edit the code within the “body_header” form, where I find the code:

<txp:section_list default_title='<txp:text item="home" />' include_default wraptag="ul" break="">
            <txp:if_status>
                <li<txp:if_section name='<txp:section />'> class="active"</txp:if_section>>
                    <a itemprop="url" href="<txp:section url />"<txp:if_section name='<txp:section />'> aria-current="page"</txp:if_section>>
                        <txp:section title />
                    </a>
                </li>
            <txp:else />
                <li>
                    <a itemprop="url" href="<txp:section url />">
                        <txp:section title />
                    </a>
                </li>
            </txp:if_status>
        </txp:section_list>

I had to hunt around a bit. I started at:
Presentation > Pages > default
As a complete newcomer to Textpattern it took me a while to realise that the code I needed was within the body_header form.

Now I just have to learn enough about Textpattern tags to work out which of your suggestions t will be best to implement in my site.

(I’m also a newcomer to Textile formatting so posting this took a while too. There’s lots to learn, but I think it will be worthwhile.

Offline

Board footer

Powered by FluxBB