Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-05-13 20:40:52

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

if section only tests current global section

Hi,
Someone very smart and witty was helping me with a drop down menu and found this issue”

“if_section doesn’t appear to test for the current section in a section list, only the current global section you are in.”

Example:
no worky:

<txp:section_list wraptag="ul" break="li" exclude="...">
<txp:section link="1" title="1"  />
<txp:if_section name="sectionwithdropdowns1,etc">
<txp:category_list section="<txp:section />" wraptag="ul" break="li" />
</txp:if_section>
</txp:section_list> 

worky:

 
<txp:section_list break="li" exclude="articles,test">
<txp:section link="1" title="1" />
<txp:php>
// sections to test for
$sections = array('eat');
global $thissection;
if (in_array($thissection['name'], $sections))
{
echo category_list(array(
		'parent'  => $thissection['name'],
		'section' => $thissection['name'],
		'wraptag' => "ul",
		'break'   => "li"
));
	}
</txp:php>
</txp:section_list> 
</ul>

Last edited by kvnmcwebn (2010-05-13 20:43:43)


its a bad hen that wont scratch itself.
photogallery

Offline

#2 2010-05-13 22:26:50

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

Re: if section only tests current global section

Right, section_list does reset the $thissection global array for each section in the list (then resets it to its initial state after the list has been produced), but does not alter the $s global. Whereas if_section just checks the value of $s.

Haven’t thought about the implications of this, but would be a simple patch to have section_list treat $s in the same way.


Code is topiary

Offline

#3 2010-05-13 22:58:17

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: if section only tests current global section

Also, you have a little error here:

<txp:category_list section="<txp:section />" wraptag="ul" break="li" />

which should be:

<txp:category_list section=’<txp:section />’ wraptag=“ul” break=“li” />

(use single quotes when tags in tags).

A way to achieve the “if_section” functionality inside a section_list loop is creating a <txp:variable name="current_section_in_loop"><txp:section /></txp:variable> and then test it with if_variable@ or doing more complex testings with smd_if plugin (if you use smd_if you don’t even need to create the variable in first place).


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#4 2010-05-14 00:05:08

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: if section only tests current global section

Cool. Thanks for explaining this and also for the other work-arounds.


its a bad hen that wont scratch itself.
photogallery

Offline

Board footer

Powered by FluxBB