Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
head_end only on certain pages
Raising a callback on admin_side:head_end
is all well and good but whatever you inject there gets added on every page. I only want the code to appear on certain tab(s). Or at the very least — if it must appear on every page — to only actually run on certain tabs.
Anyone have any clues on the best way to detect the page we’re on when inside head_end? I can’t use $event
or $step
because they are set to admin_side
and head_end
respectively. And at that point in execution we haven’t reached the <body>
, so I can’t screenscrape the id from there (which is a pretty horrible method anyway).
To prevent js code running I suppose I could read textpattern.event
and just bypass the code block if it doesn’t match the tab(s) I’m interested in, but I would prefer to simply omit the code altogether because it just slows the page rendering time down for no benefit.
Thanks in advance for any pointers. Probably something simple I’ve missed.
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
#2 2010-06-08 11:08:58
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: head_end only on certain pages
Hi Bloke,
probably this falls in one of the options you don’t want to follow, anyway you can have a look – if you already haven’t – to how Jukka/Gocom deals with it. link
Offline
Re: head_end only on certain pages
Thanks redbot. That’s quite a neat ‘n’ cheeky way round it; never thought of that.
I generally set the function signature to my_callback($event, $step) { }
which of course trashes any chance of using the globals. But if I either ditch the parameters or rename them, I can then import the event/step from the global scope and test them.
Cool, thank you very much — on behalf of Gocom :-)
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
Pages: 1