Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-06-14 12:32:20

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

php question if_section atttribute from a variable?

I’m using an array to list the sections in a template i’m making. I want to use the if_section tag to check the variable to see if it matches the current section name. Is it just not possible to pass the variable like i am doing in teh code below? I hard coded a section name into the <txp:if_section>tag’s name attribute and i changes all the tabs, so my txp tag syntax must be correct, but the variable doesn’t work though it works for the link and the link name.

Any ideas?

foreach ($tab as $section){
echo '<li<txp:if_section name="'.$section.'"> class="current_page_item"</txp:if_section>>
<a href="<txp:site_url/>'.$section.'">'.$section.'</a></li>';
}

BTW I’m trying to make a way for a user to customize a template set within a form so that the user doens’t have to alter the page template.

Offline

#2 2006-06-14 16:29:07

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: php question if_section atttribute from a variable?

Weird, looks like it should concatenate fine.

  • Are you sure your $tab array has elements and that they are not empty? Edit: I guess they are ok as you say they work in the other part of the string.
  • Maybe try constructing the string before passing it to echo?
  • If that doesn’t do it, could try slicing it into pieces, building each piece and then joining before the echo.

Last edited by net-carver (2006-06-14 16:31:12)


Steve

Offline

#3 2006-06-14 17:58:38

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: php question if_section atttribute from a variable?

<txp:php>

foreach ($tab as $section)
{
	echo '<li'.if_section(array('name' => $section), ' class="current_page_item"').'><a href="'.site_url().$section.'">'.$section.'</a></li>';
}

</txp:php>

:)

Offline

Board footer

Powered by FluxBB