Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » How do I…?
  3. » if section

#1 2010-12-16 11:21:43

dreamer
Member
Registered: 2007-06-08
Posts: 242

if section

So I’m trying to create multiple conditions for multiple sections. ie; if section A, then show this content, if section B, then show this content, etc…

Don’t think I’m doing right though:

<txp:if_section name="accessories">
   <title>Custom Accessories <txp:page_title /></title>
<txp:if_section name="dresses">
   <title>Dresses <txp:page_title /></title>
     <txp:else />
  <title>Generic Title <txp:page_title /></title>
</txp:if_section>
</txp:if_section>

Last edited by dreamer (2010-12-16 11:21:59)

Offline

#2 2010-12-16 12:01:03

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: if section

You can’t nest if_section tags.
If an article belongs to section “accessories” than it can’t belong also to section “dresses”.
I would like to show you a more appropriate example but I don’t understand what are you trying to accomplish.

Offline

#3 2010-12-16 12:17:03

dreamer
Member
Registered: 2007-06-08
Posts: 242

Re: if section

Basically, I am trying to set conditionals for my meta title. So if one section shows up, then this meta title description will appear. if another section shows up, then a different meta title will appear.

Offline

#4 2010-12-16 12:23:41

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: if section

<txp:if_section name="accessories">
	<title>Custom Accessories <txp:page_title /></title>
<txp:else />
	<txp:if_section name="dresses">
		<title>Dresses <txp:page_title /></title>
	<txp:else />
		<title>Generic Title <txp:page_title /></title>
	</txp:if_section>
</txp:if_section>

Code is topiary

Offline

#5 2010-12-18 11:42:47

ibob
Member
From: Finland
Registered: 2010-06-14
Posts: 35

Re: if section

Here’s one more solution to this if you dont want to do if_sections inside others:


<!-- Set empty variable before listing if_sections -->
<txp:variable name="section-url" value="" />
<txp:if_section name="accessories">
        <txp:variable name="section-url" value="set" />
	<title>Custom Accessories <txp:page_title /></title>
</txp:if_section>
<txp:if_section name="dresses">
        <txp:variable name="section-url" value="set" />
	<title>Dresses <txp:page_title /></title>
</txp:if_section>
<txp:if_section name="shoes">
        <txp:variable name="section-url" value="set" />
	<title>Shoes <txp:page_title /></title>
</txp:if_section>
<txp:if_section name="hats">
        <txp:variable name="section-url" value="set" />
	<title>Hats <txp:page_title /></title>
</txp:if_section>
<!-- If variable section-url not set, show generic url -->
<txp:if_variable name="section-url" value="">
        <title>Generic Title <txp:page_title /></title>
</txp:if_variable>

Offline

  1. Index
  2. » How do I…?
  3. » if section

Board footer

Powered by FluxBB