Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-10-19 20:33:00

hixster
New Member
Registered: 2012-10-19
Posts: 3

Printing which template is used into the page

Hello, first post here.

We’ve been asked to migrate a Textpattern site to another CMS and are evaluating the site in question at the moment.
I hadn’t used TP before, but from using it, it’s seems like a really nice system.

The site we are evaluating is large, with 1500+ articles, a variety of page templates (12+) and forms (30+). There is also a large amount of categories and sections.

With so many templates etc, it’s hard to figure out how some of the pages in the site are being generated and by what template/article/section/category/form. So what I started to do was simply hard code some output into some of the templates, for example, in the basic page i printed:

<p>This is the basic page template</p>

I did this on a few templates, then realised there must be a better way of doing this.

*strong*So here is my question.

Is there a single place where I can intercept/inject some PHP into the page rendering process so that the templates names get printed into the various regions of the page? I’m hoping for a result like so:

- Basic page template
— Article template
— Article template
—- Form template

and so on.

Failing that, is there a <txp> variable or attribute that can be added to a template to reveal it’s name in the rendered page?

I hope my question makes sense, please forgive me if i’m using the incorrect terminology.

Best regards and many thanks!

Offline

#2 2012-10-19 21:51:20

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Printing which template is used into the page

hixster wrote:

Hello, first post here.

Welcome to Textpattern, and sorry to see you leave so soon… ;)

Failing that, is there a <txp> variable or attribute that can be added to a template to reveal it’s name in the rendered page?

<txp:page_url type="page" /> will display the current page template’s name (page_url).

You can also find this information and more (e.g. the forms that are used in the page) in the tag trace. It requires some digging though, so you might want to look at these plugins first: adi_form_links and smd_where_used.

Offline

#3 2012-10-20 10:45:50

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

Re: Printing which template is used into the page

The OP brings up a pretty good feature request :)

<txp:output_form form="page-header" />

The form attribute is all we have right now. Bad?

Some raw thoughts:

<txp:output_form form="page-header" ouput="name" wraptag="txp:hide" />

Well, txp:hide as wraptag is pretty stupid (?) but what about htmlcomment?

<txp:output_form form="page-header" ouput="name" wraptag="htmlcomment" class="" />

Or what about a checkbox for the form which will activate an HTML comment and/or text marker around the form output?


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

Offline

#4 2012-10-20 17:28:56

hixster
New Member
Registered: 2012-10-19
Posts: 3

Re: Printing which template is used into the page

Hi guys, thanks for the kind welcome and the quick feedback. Els, thanks for your suggestion, that helped a lot.
The debug info is pretty long for the site i’m looking at and was hard to read, but <txp:page_url> helped a bit :-)

Merzi, thanks as well, i’m glad I raised something that might be of use to others. It would be super handy to be able to just switch on some rendering debugging and have each page and form within wrapped with some template info.

Cheers

Offline

#5 2012-10-20 18:14:16

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Printing which template is used into the page

hixster wrote:

It would be super handy to be able to just switch on some rendering debugging and have each page and form within wrapped with some template info.

I agree.

Offline

#6 2012-10-31 13:55:25

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: Printing which template is used into the page

hixster, you should install and activate rvm_privileged, create a form named edit-links and put the following code inside:

<txp:if_plugin name="rvm_privileged">
<txp:rvm_if_privileged level="Publisher">
<div style="float:left;" class="your-class-name">
<a href="<txp:site_url />textpattern/index.php?event=article&amp;step=edit&amp;ID=<txp:article_id />" title="Edit article">Text</a> | 
<a href="<txp:site_url />textpattern/index.php?event=page&amp;name=<txp:page_url type="page" />" title="Edit page template «<txp:page_url type="page" />»">Page</a> |
<a href="<txp:site_url />textpattern/index.php?event=form&amp;step=form_edit&amp;name=<txp:yield />" title="Edit form «<txp:yield />»">Form</a>
</div>
</txp:rvm_if_privileged>
</txp:if_plugin>

Now paste the following code at the very beginning of your forms (leaving out “edit-links”, of course):

<txp:output_form form="edit-links"><txp:php>global $txp_current_form;echo $txp_current_form;</txp:php></txp:output_form>

Please be aware this is altered code, condensed and translated, that I didnt find the time to test yet.

The snippets in use create links that lead from the front side immediately into the correct pages on the Write panel, in Page templates and in the Forms in use by the page you’re looking at. Only users logged in in TXP’s admin can view these links, and only if rvm_privileged is installed, both making it easily deployable and uncomplicated. You can adjust immediately inside the rvm_privileged tag who exactly is allowed to edit, or even surround parts of the code with additional rvm_privileged tags in order to let different groups edit texts than code.

Requirements: TXP 4.5.n (where n could be even 2, can’t tell) and rvm_privileged
In case you’ve a version of TXP minor than 4.5 you have to type the actual form names manually, i.e. if you add the output_form line of code to the default form, the line should say:
<txp:output_form form="edit-links">default</txp:output_form>.

Once you’ve understood the relations between your forms (or when working on installations you’ve created), you can reduce the amount of output_form tags in your forms, that is cluttering your front of site pages, and instead lean more on the use of the plugin Els recommended, adi_form_links, for moving into nested forms.

Last edited by uli (2012-10-31 13:59:28)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB