Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2022-12-18 19:52:50

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

How to access a form, from a specific theme please?

Hi,
I have multiple themes, I want to access a specific form, from a specific theme without having different names for the forms, how can this be done please?
My main use for this is for the rah_external_output plugin.
Example url: https://example.com/?rah_external_output=example
Can it be something like this?
https://example.com/my-theme-name1/?rah_external_output=example
https://example.com/my-theme-name2/?rah_external_output=example

Also, how to access a form, from a different theme using <txp:output_form /> or using PHP please?

Offline

#2 2022-12-18 19:55:46

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: How to access a form, from a specific theme please?

BTW: is there a new replacement for the rah_external_output plugin nowadays please?
maybe something in the core of the new TXP?

Offline

#3 2022-12-19 04:33:31

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

Re: How to access a form, from a specific theme please?

THE BLUE DRAGON wrote #334320:

BTW: is there a new replacement for the rah_external_output plugin nowadays please?
maybe something in the core of the new TXP?

It is indeed in house now.

Go to Preferences>Admin>Advanced options and enable it.

Now there should be a new Advanced options link on the left menu. Click on it,and you will see three fields. This is how I populated them.

PHP functions enabled in txp:evaluate: md5, replace:preg_replace

Custom form template types Help:


;[js]
;mediatype="application/javascript"
;title="JavaScript"
[js]
mediatype="application/javascript"
[json]
mediatype="application/json"
[svg]
mediatype="image/svg+xml"
[xml]
mediatype="application/xml"
[txt]
mediatype="text/plain"
[csv]
mediatype="text/csv"
[htm]
mediatype="text/html"
[html]
mediatype="text/html"

Number of extra parser sweeps: 1

You can access the outputs similarly to how the rah_external_output plugin did. domain.tld/?f=form_name.


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

Offline

#4 2022-12-19 09:19:44

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

Re: How to access a form, from a specific theme please?

In addition to what Yiannis said, if you want to get the theme name that is in force at any point, you can use the page_url tag:

<page::url type="theme" />

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 2022-12-19 11:57:41

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

Re: How to access a form, from a specific theme please?

THE BLUE DRAGON wrote #334319:

I have multiple themes, I want to access a specific form, from a specific theme without having different names for the forms, how can this be done please?
My main use for this is for the rah_external_output plugin.
Example url: https://example.com/?rah_external_output=example
Can it be something like this?
https://example.com/my-theme-name1/?rah_external_output=example
https://example.com/my-theme-name2/?rah_external_output=example

Typically, themes are associated with sections, so this could be

https://example.com/section-of-theme-name1/?rah_external_output=example
https://example.com/section-of-theme-name2/?rah_external_output=example

Untested with rah_external_output plugin, but this should work with core custom forms, once you set them up.

Also, how to access a form, from a different theme using <txp:output_form /> or using PHP please?

At some moment it was decided that crossing a section (and thus theme) boundary would be a privacy/security risk, so you need php privs here:

<txp:php>
<!-- fetch a form without parsing -->
$form = fetch_form('my-form', 'my-theme');

<!-- or parse and output it -->
echo parse_form('my-form', 'my-theme');
</txp:php>

Offline

#6 2022-12-29 19:25:24

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: How to access a form, from a specific theme please?

Thank you all very very much colak, Bloke, etc, it is always great to learn on new features and stuff in TXP 🤗💗
Happy new year 🎉🥳

Offline

Board footer

Powered by FluxBB