Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2009-05-28 15:52:01
- MattH
- Member
- From: Ann Arbor, MI
- Registered: 2004-10-17
- Posts: 30
[resolved] <txp:section /> changes itself?
I use <txp:section /> multiple times on a page. After processing some articles, it changes, no longer reflecting the current section. This behavior occurs even though the section tag is not placed in a display form — it is placed in the main template flow.
Any ideas on how I can get txp:section to always refer to the section specified in the URL?
Offline
Re: [resolved] <txp:section /> changes itself?
Mmmm… are you using it inside an article form? Inside an article form, it returns the current rendered article section.
If not, then, are you using TXP 4.0.7? If I’m not wrong, there was a bug on TXP 4.0.7 where txp:section didn’t “reset” to the current section value after being used inside txp:section_list. But not sure if your problem is related to this.
In any case, a tag trace will be helpful to diagnose/debug.
Offline
#3 2009-05-28 15:55:57
- MattH
- Member
- From: Ann Arbor, MI
- Registered: 2004-10-17
- Posts: 30
Re: [resolved] <txp:section /> changes itself?
With more investigation, it looks like section(array()) also changes value.
But I see no reason for this change, unless section(array()) always returns the section of the previously displayed article.
Offline
Re: [resolved] <txp:section /> changes itself?
Being that we posted within one second lap, you may have missed my reply ^ ^.
Offline
#5 2009-05-28 16:17:12
- MattH
- Member
- From: Ann Arbor, MI
- Registered: 2004-10-17
- Posts: 30
Re: [resolved] <txp:section /> changes itself?
Thanks for those tips. I’m using 4.08, will report back soon.
Is there a way to make a variable set in <txp:php> accessible outside of that block? I tried creating something like:
global $section-hold;
$section-hold = section(array());
But the variable goes out of scope after the txp:php block closes
Offline
#6 2009-05-29 16:34:37
- MattH
- Member
- From: Ann Arbor, MI
- Registered: 2004-10-17
- Posts: 30
Re: [resolved] <txp:section /> changes itself?
Another interesting finding—
If I display in this order:
1. <txp:section />
<txp:variable name=“the-section” value=”<txp:section />” />
2. <txp:variable name=“the-section” />
3. <txp:section />
The sections are printed:
1. correct section
2. wrong section
3. correct section
For some reason, the variable is set incorrectly. The tag trace output doesn’t help; it doesn’t show the values of the tags as evaluated.
Edit: But it works using <txp:asy_wondertag>, as in:
1. <txp:section />
<txp:asy_wondertag><txp:variable name=“the-section” value=”<txp:section />” /></txp:asy_wondertag>
2. <txp:variable name=“the-section” />
3. <txp:section />
Last edited by MattH (2009-05-29 16:35:54)
Offline
#7 2009-05-29 16:39:53
- net-carver
- Archived Plugin Author
- Registered: 2006-03-08
- Posts: 1,648
Re: [resolved] <txp:section /> changes itself?
Try…
<txp:section />
<txp:variable name=“the-section” value='<txp:section />' />
NB: use single quotes for enclosed tags.
— Steve
Offline
Re: [resolved] <txp:section /> changes itself?
When nesting txp tags in txp tags, you need to use single quotes.
Wrong:
<txp:variable name=“the-section” value=”<txp:section />” />
Correct:
<txp:variable name=“the-section” value='<txp:section />' />
Edit: net-carver was faster.
Last edited by maniqui (2009-05-29 16:42:51)
Offline
#9 2009-05-29 17:20:29
- MattH
- Member
- From: Ann Arbor, MI
- Registered: 2004-10-17
- Posts: 30
Re: [resolved] <txp:section /> changes itself?
Thanks for the solution. I find it odd that the tag still evaluated, though — Textpattern always seems to either (a) insert only the expected content or (b) fail gracefully by displaying nothing. I hadn’t seen it assume an answer before.
Offline
Re: [resolved] <txp:section /> changes itself?
I added your code to a test page with no other content and got the same section for all three.
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline