Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2010-09-15 22:26:52
- Enor
- Member
- From: London, UK
- Registered: 2010-09-02
- Posts: 26
Using <txp:section_list />
Hi
I have this in place for my form named navigation:
<txp:section_list wraptag=“ul” break=“li” include_default=“1” default_title=“home” sections=”, about, process, portfolio, contact, blog” />
But I want it to output the code as:
<ul>
<li class=“home-link”><a href=”/”>Home</a></li>
<li class=“about-link”><a href=”/about”>About – Who are we</a></li>
<li class=“process-link”><a href=”/process”>Process – What we do</a></li>
<li class=“portfolio-link”><a href=”/portfolio”>Portfolio – Our clients</a></li>
<li class=“contact-link”><a href=”/contact”>Contact – Get in touch</a></li>
<li class=“blog-link”><a href=”/blog”>Blog – The latest</a></li>
</ul>
How would I do this?
Plus I want the additional text after the hyphen too e.g. “What we do” but I do not want to add it to my section title in the sections page. Is this possible in Textpattern?
Offline
Re: Using <txp:section_list />
Yes, it can be done.
There’s no standard way to add extra data to sections, as with the descriptions you want. You could do it with a big a stack of conditionals, but it would be a pain to debug and maintain.
Or you could also put the descriptions into articles, one for each section, assigning them a special category, and calling up the descriptions with an article_custom
tag inside your section list. That’s not a bad solution.
If I had to do this I’d probably use some raw PHP in a form, and make use of the rather cool yield
function. Just note that making a syntax error in the raw PHP can take your site completely offline, so don’t experiment with this on a production site.
In your page template:
<txp:section_list wraptag="ul" sections=",about,process,portfolio,contact,blog" default_title="Home">
<li class="<txp:section />"-link"><a href="<txp:section url="1" />"><txp:section title="1" /><txp:output_form form="section_descriptions"><txp:section /></txp:output_form></a></li>
</txp:section_list>
In the form named “section_descriptions”:
<txp:php>
$desc = array(
'default' => '',
'about' => ' - Who we are',
// etc. for remaining sections
);
echo $desc[yield()];
</txp:php>
Untested, ymmv :)
Last edited by jsoo (2010-09-16 01:49:26)
Code is topiary
Offline
#3 2010-09-16 01:52:37
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Using <txp:section_list />
Are you aware that you can assign section names and section titles? Thus, your section name could be “process” while its title is “Process – What we do”. Then you could use the section list tag as a container tag wrapped around the following section tag <txp:section link="1" title="1" class='<txp:section />-link' wraptag="li" />
, and the list of sections would automatically be updated every time you add one to your site.
If, however, you need three variants of section’s denotations, we’d need someone with a real idea.
EDIT: Seems like the one with the real idea was even faster than me :)
Last edited by uli (2010-09-16 02:01:21)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Using <txp:section_list />
I suppose a safer route would be to use the variable
tag. More elegant, too. Especially if I remember to use section
as a container tag :)
<txp:variable name="default" value="" />
<txp:variable name="about" value=" - Who we are " />
<!-- and so on for each section -->
<txp:section_list wraptag="ul" sections=",about,process,portfolio,contact,blog" default_title="Home">
<li class="<txp:section />"-link"><txp:section><txp:section title="1" /><txp:variable name='<txp:section />' /></txp:section></li>
</txp:section_list>
Note the single quotes around the section
tag inside the variable
tag.
Code is topiary
Offline
#5 2010-09-16 06:34:20
- Enor
- Member
- From: London, UK
- Registered: 2010-09-02
- Posts: 26
Re: Using <txp:section_list />
Hi Guys
Thanks for your responses….
Jeff I tried yours and it worked as intended:
<txp:variable name=“default” value=”“ />
<txp:variable name=“about” value=” – Who we are” />
<txp:variable name=“process” value=” – What we do” />
<txp:variable name=“portfolio” value=” – Our clients” />
<txp:variable name=“contact” value=” – Get in touch” />
<txp:variable name=“blog” value=” – The latest” />
<txp:section_list wraptag=“ul” sections=“home,about,process,portfolio,contact,blog” default_title=“Home”>
<li class=”<txp:section />-link”><txp:section><txp:section title=“1” /><txp:variable name=’<txp:section />’ /></txp:section></li>
</txp:section_list>
But when I look at the source code, for each <li> produced a <br /> appears. How do I remove the <br /> ?
Offline
Re: Using <txp:section_list />
I think you will need to add break=""
to the <txp:section_list />
tag. It has a default value of “br”.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#7 2010-09-16 07:18:34
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Using <txp:section_list />
Enor wrote:
But when I look at the source code, for each <li> produced a <br /> appears. How do I remove the <br /> ?
You need to add break=""
to the section_list tag, because this attribute’s default value is br
.
Edit: late again ;)
Last edited by els (2010-09-16 07:19:03)
Offline
#8 2010-09-16 08:16:14
- Enor
- Member
- From: London, UK
- Registered: 2010-09-02
- Posts: 26
Re: Using <txp:section_list />
Thanks Els :)
Offline
Pages: 1