Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2023-01-24 09:43:46

trenc
Plugin Author
From: Malmö
Registered: 2008-02-27
Posts: 572
Website GitHub

txp:variable in plugin

Hi there,

probably I’m very stupidly overlooking something here. But how can I access the global $variables in a plugin, say admin side?

The variables a decleared in a form (with <txp:variable name="this_name" value="this_value" />). I tried to parse that form (parse_form()) in the plugin but it seems that they are somewhere else populated into the global namespace not just by parsing. The globals $variables remains null.

Can someone enlighten me.

Thanks in advance.

Offline

#2 2023-01-24 11:24:10

trenc
Plugin Author
From: Malmö
Registered: 2008-02-27
Posts: 572
Website GitHub

Re: txp:variable in plugin

Never mind. Figured it out. For future reference:


global $variable;

require_once(txpath . '/lib/txplib_publish.php');
require_once(txpath . '/publish/taghandlers.php');
require_once(txpath . '/lib/txplib_html.php');

$form = safe_field('Form', 'txp_form', "name = 'form_name_with_txp_variables'");
parse($form);

// now we have access to the $variables
dmp($variable);

Offline

Board footer

Powered by FluxBB