Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: adi_variables - Manage TXP variables
I’m loving this – Thanks gomedia :)
I know it was mentioned on the first page – but adi_variables would be godly if it was possible to cross it with glz_custom_fields (especially for creating themes with options)
Possibilities would be endless
(if this board had icons, I’d use the hide behind the sofa one)
Offline
Re: adi_variables - Manage TXP variables
Hi Adi et all.
Here is a mod to v0.3.1 that makes adi_variables to update the “lastmod” preference when a variable is added/modified/deleted.
This mod makes adi_variables play nice with aks_cache, in the sense that, with this mod, the “Reset cache if site was updated” will be triggered (when visiting a page in front end) if you added/modified/deleted a variable.
if ($step == 'update') {
$new_name = trim(ps('new_var'));
// validate new variable name
if (strpos($new_name,' '))
$message = 'spaces not allowed in variable name';
if (strpos($new_name,'"') || strpos($new_name,"'"))
$message = 'quotes not allowed in variable name';
if (ps('ps_name')) // then other variables exist (i.e. this is not the first)
if (array_key_exists($new_name,ps('ps_name')))
$message = "$new_name already exists";
// add new variable to form
if ($message == '') {
$new_form = adi_variables_form_update(ps('ps_name'),ps('ps_public'),$new_name,ps('new_value'),ps('new_public'));
$ok = adi_variables_update(join("\n",$new_form));
$ok ?
$message = "updated" :
$message = "update failed";
}
// MOD: update value for "lastmod" preference when a variable is successfully added/updated.
if ($ok) {
update_lastmod();
}
// END_MOD
}
if ($step == 'delete') {
if (has_privs($admin_privs)) { // double check privileges because this operation uses GET VARS
$new_form = adi_variables_form_delete($this_variable);
$ok = adi_variables_update(join("\n",$new_form));
$ok ?
$message = "$this_variable deleted" :
$message = "delete failed";
}
else
$message = "insufficient privileges";
// MOD: update value for "lastmod" preference when a variable is successfully deleted.
if ($ok) {
update_lastmod();
}
// END_MOD
Offline
#51 2011-10-11 00:44:37
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_variables - Manage TXP variables
Hi Julián,
Looks like a very sensible thing to do, thanks. I’ll include it in the next update.
Adi
Offline
#52 2011-10-26 05:30:43
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_variables - Manage TXP variables
Version 0.4, which incorprates maniqui’s lastmod mod, is available for download.
Offline
Re: adi_variables - Manage TXP variables
Thanks, Adi.
Not sure if intentionally, but I’m letting you know that the plugin shows as v0.4beta (and the opening post of this thread still doesn’t mention this new version).
Offline
#54 2011-10-30 23:08:39
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_variables - Manage TXP variables
maniqui wrote:
… I’m letting you know that the plugin shows as v0.4beta (and the opening post of this thread still doesn’t mention this new version).
Oops, I’ve fixed that up. If you redownload the plugin, it should show up as 0.4 and I’ve edited the first post.
Offline
Re: adi_variables - Manage TXP variables
Hi Adi,
I installed “adi_variable 0.4”.
Is there a solution for make it work with cnk_versionning?
A request for Maniqui and johnstephens in 2009
Thanks
Offline
Re: adi_variables - Manage TXP variables
Hi sacripant.
There is this modded version of cnk_versioning which works with adi_variables. In the plugin code, there is a hardcoded list of forms/pages/css to ignore (adi_variable is listed by default).
Adi, I was thinking this the other day: why not save the adi_variables on its own table (or maybe just in prefs table? because, it’s just one entry…). The only “backward compatibility” issue I see is that you may need to create a tag to include the vars, as txp:output_form
probably won’t work, as the “form” holding the adi_variables, well, won’t be located in the “txp_form” table…
Offline
#57 2011-12-28 21:10:15
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_variables - Manage TXP variables
maniqui wrote:
Adi, I was thinking this the other day: why not save the adi_variables on its own table (or maybe just in prefs table? because, it’s just one entry…). The only “backward compatibility” issue I see is that you may need to create a tag to include the vars, as
txp:output_form
probably won’t work, as the “form” holding the adi_variables, well, won’t be located in the “txp_form” table…
Hi maniqui – thanks for helping sacripant out.
WRT an adi_variables database table – I’m not sure about that. On reflection, I quite like the way the variables are in “plain sight” – i.e. visible to eyeballs & smd_where_used. And I don’t think the prefs table is really the place to put them either.
Offline
Re: adi_variables - Manage TXP variables
Hi Aid.
A little question. Why must use a form? You can’t call a function that get all variable set public and insert them into an global $variable array?
Offline
#59 2012-10-16 00:09:00
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_variables - Manage TXP variables
MarcoK wrote:
A little question. Why must use a form? You can’t call a function that get all variable set public and insert them into an global $variable array?
Hi Marco. Just stumbled across your query. Apologies for not addressing it sooner.
To answer your question, the variable values have to be stored somewhere. I chose to do it in a form, using txp:variable tags – for several reasons. Firstly it seemed like a good idea at the time, secondly it was visible (e.g. to smd_where_used), and thirdly it could be edited manually just like any other form. The other advantage is that by setting up the variables using standard txp:variable tags, I’m covered if the internal variable system changes.
The other option is to store the values in a separate database table, which has been requested before – and despite being stubborn, I haven’t totally discounted! Just want to concentrate on the 4.5 updates at the moment.
Offline
#60 2012-10-16 00:44:18
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_variables - Manage TXP variables
Version 0.5 now available
- TXP 4.5-ified
- tooltips no more
- Textpack
- code tidy up
- fix: update button now not shown for non privileged users when there’re no public variables
- enhancement: variable rename for Admin users
As always, take a backup of your adi_variables form before upgrading.
Offline