Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-01-10 13:02:09

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

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

#2 2011-01-10 15:09:15

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: On-off switch for txp:hide

Not bad. Maybe we can marry your switch ‘state’ with my txp:hide timer request :)

txp:hide – date attributes ‘showstart’ and ‘showend’


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#3 2011-01-10 15:17:04

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

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,304

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

#5 2011-01-13 12:52:51

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

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

#6 2011-01-13 12:55:46

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

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

#7 2011-01-13 13:58:20

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

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

#8 2011-01-13 14:05:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: On-off switch for txp:hide

colak wrote:

it would be tedious to find the on/off switchs

Would it? :-)


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

#9 2011-01-13 14:13:39

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: On-off switch for txp:hide

Bloke wrote:

Would it? :-)

I know:) It is one of my must have plugins:)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#10 2011-01-13 16:33:10

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

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

#11 2011-01-13 20:21:36

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

#12 2011-01-13 20:29:04

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

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.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB