Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2010-11-20 04:33:35
- kevinpotts
- Member
- From: Ghost Coast
- Registered: 2004-12-07
- Posts: 370
plugin to test which page template a section uses?
I thought awhile ago I saw a conditional plugin that tested what page template a given section was associated with. Am I crazy?
Kevin
(graphicpush)
Offline
Re: plugin to test which page template a section uses?
Kevin – I don’t know if this is what you are thinking of, but I think I recall there was a discussion about testing a page, or form before allowing it to be deleted.
But I can’t remember if it was a plugin or a patch to the core.
Last edited by maverick (2010-11-20 15:11:03)
Offline
#3 2010-11-20 14:54:04
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: plugin to test which page template a section uses?
I guess you can use smd_query to get the information, and put it in a txp:variable?
Offline
Re: plugin to test which page template a section uses?
A little php code is better than separate plugin, I think:
<txp:php>
global $variable, $s;
$variable['page_template'] = safe_field("page","txp_section","name='$s'");
</txp:php>
And let test – <h1><txp:variable name="page_template" /></h1>
produces <h1>default</h1>
at my site.
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline
#5 2010-11-20 19:42:22
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: plugin to test which page template a section uses?
Really cool, Victor! Thanks! This completes my collection of edit links, i.e. links from the front side that go immediately into the right place in the admin side.
For forms I use output_form and a yield tag, which works perfectly well, but is a method that forces me to write down the form name a second time. How would you collect info on the form name using PHP?
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: plugin to test which page template a section uses?
I think you can simplify Victor’s code a bit:
<txp:php>
global $page, $variable;
$variable['page_template'] = $page;
</txp:php>
though I haven’t tested this.
Code is topiary
Offline
#7 2011-09-10 14:55:29
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: plugin to test which page template a section uses?
Update: <txp:page_url type="page" />
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline