Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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).
Offline
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