Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » How?
  3. » Section Order

#1 2009-12-18 09:54:01

koobs
Member
Registered: 2008-11-25
Posts: 27

Section Order

Hi all,

Edit: I’ve worked out a lot of my original questions… and to simplify I’ve edited this post.

Can someone please advise – what is the best way for a (non-technical) author to control the sort order of a section menu?

I’d prefer them not to be messing with forms.

I searched for plugins but I’m surprised there doesn’t seem to be anything :(

Any pointers appreciated

I read the tips here on how to create a dropdown menu which was great but I need something that was a little more dynamic. I read about <txp:if_different> but didn’t really understand it and couldn’t get it to work (wasn’t sure if it was necessary) but after some trial and error I got a solution to work using…

bc. <txp:section_list default_title=’<txp:text item=“home” />’ include_default=“1” wraptag=“ul” break=”“ exclude=“frontpage,search” form=“navbuild” />

bc. <li><txp:section link=“1” title=“1” /><txp:article_custom section=’<txp:section />’ status=“live” form=“navbuildlinks” wraptag=“ul” sort=“Posted asc” class=“subnav” /></li>

I’m hoping that this will prove reliable – What I’m trying to do now is find a way for a client to control what sections, and in which order, go into the main navigation structure.

I know I can set the sort order and exclude in the first block of code but is there any way I could make this easily done by an author, by a plugin perhaps?

Any tips or advice would be greatly appreciated.

Last edited by koobs (2009-12-22 16:53:34)

Offline

#2 2010-01-01 15:01:42

koobs
Member
Registered: 2008-11-25
Posts: 27

Re: Section Order

Hey all,

Anyone have any ideas?

Last edited by koobs (2010-01-01 15:02:16)

Offline

#3 2010-01-01 15:22:38

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,467

Re: Section Order

See in txp:section_list the attributes “sections” and “sort”.

Offline

#4 2010-01-01 15:24:01

koobs
Member
Registered: 2008-11-25
Posts: 27

Re: Section Order

Thanks but I am wondering if there is a way for a client to reorder sections without editing forms.

Offline

#5 2010-01-01 15:25:21

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Section Order

If you don’t want to give the author access to forms or page, this is a way to do it using an article. It’s not perfect though, and maybe someone else comes up with a better idea.

Create a section, for example ‘admin-only’. Make sure you don’t link to it anywhere on the site. In this section, create an article, for example ‘Section order’. Turn Textile off for this article. Just write the section names in the article body, separated by commas. You can also do this in the excerpt field, and use the body for instructions how to use it. For the section list you can use something like this on your page:

<txp:section_list sections='<txp:article_custom id="123"><txp:body /></txp:article_custom>' />

(or <txp:excerpt /> in case you used the excerpt field of course)
The article has to be live or sticky to be used in this way, so you’ll need to make sure that it won’t show up in some article list on the site ;)

Offline

#6 2010-01-01 15:40:38

pogonik
Member
Registered: 2008-03-20
Posts: 40
Website

Re: Section Order

I’ve find easy way to control section order by section name (not Title)…for example, you (or client) can name sections “01-news”, “02-about”, “03-portfolio”, etc.

I think that SEO in urls won’t be a problem because of “-” between number and section name.

then just add <txp:section_list /> and that’s it.

Offline

#7 2010-01-01 15:40:51

koobs
Member
Registered: 2008-11-25
Posts: 27

Re: Section Order

Thanks Els,

Works perfectly – a little bit quirky but equally clever

Offline

#8 2010-06-28 15:46:32

dsgnr
New Member
Registered: 2010-06-28
Posts: 1

Re: Section Order

pogonik wrote:

I’ve find easy way to control section order by section name (not Title)…for example, you (or client) can name sections “01-news”, “02-about”, “03-portfolio”, etc.

I think that SEO in urls won’t be a problem because of “-” between number and section name.

then just add <txp:section_list /> and that’s it.

Thank you for quick easy tip.
This has worked, but uncertain where <txp:section_list /> is to be added.

Last edited by dsgnr (2010-06-28 15:47:49)

Offline

#9 2011-03-10 16:05:06

nabrown78
Member
From: Boston, MA, USA
Registered: 2006-10-04
Posts: 291
Website

Re: Section Order

Els wrote:

If you don’t want to give the author access to forms or page, this is a way to do it using an article. It’s not perfect though, and maybe someone else comes up with a better idea.

Create a section, for example ‘admin-only’. Make sure you don’t link to it anywhere on the site. In this section, create an article, for example ‘Section order’. Turn Textile off for this article. Just write the section names in the article body, separated by commas. You can also do this in the excerpt field, and use the body for instructions how to use it. For the section list you can use something like this on your page:

<txp:section_list sections='<txp:article_custom id="123"><txp:body /></txp:article_custom>' />

(or <txp:excerpt /> in case you used the excerpt field of course)
The article has to be live or sticky to be used in this way, so you’ll need to make sure that it won’t show up in some article list on the site ;)

I thought I was being clever, but Els’ method is actually simpler. The following is a little more “whizzy” I guess:

  • Install the plugin stm_article_order recently updated by Uli
  • create a section called something like “Section Order” or “Section Sort”
  • for each section that you want to display in your main nav, create an article with a title matching that of the section name
  • then use <txp:section-list /> like so:
  <txp:section_list sections='<txp:article_custom section="section-order" sort="position asc"><txp:article_url_title />,</txp:article_custom>' active_class="current" wraptag="ul" break="li" class="" />

I am using <txp:article_url_title /> rather than just <txp:title /> because I anticipate when a client might add a “section article”, if you will, and accidentally make it uppercase or forget the hyphen or something. At least using <txp:article_url_title /> would account for those errors.

I also thought you could just do something like:

<ul>
<txp:article_custom section="section-order" sort="position asc">
    <li><a href="/<txp:article_url_title />"><txp:title /></a></li>
</txp:article_custom>
</ul>

But then the “Section Title” isn’t baked in, and you lose the easy active_class functionality.

Anyhoo, with this in place, you or your client can reorder the nav menu simply by reordering the articles in the “Section Order” section, using the nice interface of stm_article_order.

Offline

#10 2011-03-10 16:24:15

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,256

Re: Section Order

Nora, I like this! Nicely thought outside the box.

As you can see from the category separator articles I used in my version of stm_article_order, i have a sense of converting, reusing and channeling things into others. :)

Thanks for posting this trick!

Last edited by uli (2011-03-10 17:17:53)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#11 2011-03-11 00:00:29

radneck
Plugin Author
Registered: 2005-07-03
Posts: 109

Re: Section Order

Offline

  1. Index
  2. » How?
  3. » Section Order

Board footer

Powered by FluxBB