Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-10-10 18:00:46

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

How do I find the name of the article form being used?

How do I find the name of the article form being used? I’m cheating by using:

<txp:custom_field name="override_form" />

…is there a more graceful way, please? Thank you.

Offline

#2 2020-10-12 16:48:55

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

Re: How do I find the name of the article form being used?

Hi Pete, makss once posted this code:

<txp:php>global $txp_current_form;echo $txp_current_form;</txp:php>

Or can this be done now with core tags?


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

Offline

#3 2020-10-12 19:10:27

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: How do I find the name of the article form being used?

I guess the page source in debug mode is not an option? Then for override forms <txp:custom_field /> looks ok. We have no tag for the current form, but could expose it if needed for other purpose than debugging.

Offline

#4 2020-10-12 21:38:19

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

Re: How do I find the name of the article form being used?

Can <txp:page_url /> expose 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

#5 2020-10-13 06:08:46

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: How do I find the name of the article form being used?

etc wrote #326342:

[…] but could expose it if needed for other purpose than debugging.

It’s presentational, not debugging. I’m building a template that uses different header/main/aside/footer scaffolds depending on the article form. That is to say, the article form dictates which forms are pulled in for presentation elsewhere (individual article only, not article list and otherwise).

Last edited by gaekwad (2020-10-13 10:08:28)

Offline

#6 2020-10-13 09:56:27

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: How do I find the name of the article form being used?

gaekwad wrote #326345:

It’s presentational, not debugging.

Couldn’t you just set a variable?

Offline

#7 2020-10-13 10:10:20

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: How do I find the name of the article form being used?

michaelkpate wrote #326351:

Couldn’t you just set a variable?

That’s sort of what I’m doing with…

<txp:custom_field name="override_form" />

…but I’m using the ‘hidden’ custom field over the legit ones. Or have I misunderstood you?

Last edited by gaekwad (2020-10-13 10:22:51)

Offline

#8 2020-10-13 10:26:56

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

Re: How do I find the name of the article form being used?

The custom field hack works fine as long as there is an override_form specified for the article. If not, you’ll get nothing back. Thus, it’d be nice to be able to expose this officially, with support for forms that are part of the template as well as override_forms.

Testing a form name is a legitimate thing to do and, especially with the override_form enhancements coming in 4.8.4, it’ll give some great scope for conditional branching based on which form is in use…

EDIT: e.g. if this page is using the ‘gallery’ form or ‘grid’ form, then load this additional lightbox script for handling stuff on this page.

You could employ such a conditional in the form that handles your end-of-body-tag scripts, which gives you nice control over where to load additional non-blocking scripts, instead of having to do it in the form itself, which’d appear mid-page in the markup. Plus, if it was a repeated form, called many times for a list of items, you’d have to use additional logic such as if_last_whatever to ensure you only output the script once. Being able to detect the current form in use for the page would be a boon here.

Not sure what would happen if you called a form from within a form (from within a form, …) though. What’s the scope? We could do with being able to get at ‘thisform’ (possibly nested) and ‘the main form in use on the page’ (top-level) at minimum, imo. Possibly some delimited hierarchy too, so we could assign it to a variable and do something like: <txp:if_variable name="forms-tree" match="any" delimiter="|" value="gallery">...</txp:if_variable>.

Last edited by Bloke (2020-10-13 10:35:58)


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 2020-10-13 11:16:57

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: How do I find the name of the article form being used?

Bloke wrote #326355:

What’s the scope?

High level: author selects the form for the article, that dictates the presentation of the main content, whether it’s full-width, n-column, or something else…which also affects any aside stuff, and there’s optional scope to redo the nav, header and footer stuff depending on what main looks like. If there’s a full-bore, image-heavy article, the top matter needs to be presented accordingly, and likewise if it’s a more subtle thing then it can be toned down.

Offline

#10 2020-10-13 16:03:30

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

Re: How do I find the name of the article form being used?

etc wrote #326342:

I guess the page source in debug mode is not an option?

Right. At least for my purpose it’s always been about offering links for publishers and designers from the front side to the admin in order to ease form editing.

Last edited by uli (2020-10-13 18:00:07)


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

Offline

Board footer

Powered by FluxBB