Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
On-off switch for txp:hide
function hide($atts, $thing = NULL)
{
extract(lAtts(array(
'state' => 1,
), $atts));
return $state ? '' : parse($thing);
}
Why? For testing/debugging it is sometimes helpful to add arbitrary code blocks, hiding and revealing them as needed. It would be handy to be able to switch a block on and off by changing just one character, instead of having to add/remove hide
tags.
Code is topiary
Offline
Re: On-off switch for txp:hide
Not bad. Maybe we can marry your switch ‘state’ with my txp:hide timer request :)
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
Re: On-off switch for txp:hide
I like your idea, although I think it really belongs in a separate if_date
tag, as you suggested in that topic.
Code is topiary
Offline
#4 2011-01-13 12:40:39
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: On-off switch for txp:hide
+1
This’d make a really useful feature! Code sometimes can get so much exuberant and unwieldy to throw in and remove the hide tags again and again.
(I’d just name it a little more speaking like, perhaps, active
.)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: On-off switch for txp:hide
uli wrote:
(I’d just name it a little more speaking like, perhaps,
active
.)
Actually, I’d find that confusing. What’s active, the hide action or the enclosed code? Almost any attribute name I can think of has that problem. state
, being more abstract, seems less likely to lead to misinterpretation. But maybe:
<txp:hide show="1" />
Code is topiary
Offline
Re: On-off switch for txp:hide
I’ll happily implement <txp:hide off="on" />
and let the wiki authors sort it out ;) Oh, the difficulties of naming…
Offline
Re: On-off switch for txp:hide
it would be tedious to find the on/off switchs though pages/forms/articles. Wouldn’t it be better if there was a preference for it?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: On-off switch for txp:hide
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: On-off switch for txp:hide
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: On-off switch for txp:hide
Adding an option for global on/off based on the site’s production status might be a nice feature. Though really I think that would be better handled by an if_production_status value="debugging"
or if_debugging
tag.
Code is topiary
Offline
Re: On-off switch for txp:hide
If you don’t mind changing 2 characters instead of one, you could simply add a character after the “<” in the TXP tag: <xtxp:hide>
and </xtxp:hide>
aren’t recognised as TXP tags and likely won’t affect HTML rendering either.
Offline
Re: On-off switch for txp:hide
^^ For short chunks of code, ruud’s trick is nice. For large chunks, an attribute seems the way to go.
Offline