Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-10-26 12:03:32

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

adi_variables - Manage TXP variables

Summary

adi_variables is a user friendly admin interface for managing TXP variables.

Once installed and activated, you’ll get:

  • a new Variables tab under Content to manage your variables
  • a new form, adi_variables, to store the variables

See the help supplied with the plugin, or have a look online.

Admin tab features

This provides:

  • a list of variables & their current values
  • the ability to add, delete, update & rename variables
  • options to make variables Admin or Public
  • drag & drop reordering*
  • an admin function to take a backup of the ‘adi_variables’ form

*Note that the variables will still be in two groups – Admin or Public.

Admin & Public

Because TXP variables have been implemented as a tag and hence used in forms/pages etc, the distinction between ‘Admin’ and ‘Public’ kicks in a long way down the food chain. Basically, anybody apart from Staff Writer & Freelancer has access to Forms – so it’s only these two user privs that can sensibly be restricted.

Admin users can add, delete, update or rename any of the variables.

Public users (i.e. Staff Writer & Freelancer) have visibility of all variables but can only update the ‘Public’ ones.

By making variables ‘Public’, you’re giving Staff Writer & Freelancer users the ability to modify them. Normally they wouldn’t be able to edit the forms containing the <txp:variable /> entries. They still, however, can’t delete or add variables.

Version History

  • 0.7
    • minor updates for TXP 4.6
  • 0.6
    • TXP 4.5+ only
    • tested on TXP 4.6
    • plugin privileges in options
    • drag & drop reordering
    • minor UI improvements
  • 0.5
    • 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
  • 0.4
    • use update_lastmod() (thanks maniqui)
  • 0.3.1
    • fixed: unable to see variables in admin after manual edit (thanks woof)
  • 0.3
    • will handle single and double quotes in variable values
  • 0.2
    • copes with TXP tags in variable values
  • 0.1
    • initial release

Textpack

There is a mechanism to install a Textpack in the adi_variables options page under the Plugins tab.

Corrections or additional language translations are most welcome and can be submitted here.

Languages currently available, thanks to:

  • French (Pat64)
  • Czech (mikulas)
  • Polish (thanks BKawalec)

Requirements

  • Textpattern 4.5+

Download & Installation

Download adi_variables and install the plugin in the usual way.

A new form, called adi_variables, will be created when you visit the Variables tab for the first time.

Delete the example variables and add your own.

To bring them into operation put this line of code:

<txp:output_form form="adi_variables" />

at the top of all your web pages.

Note that you can still define other variables, using <txp:variable />, elsewhere in your pages.

Bugs & Limitations

  • Variables defined by adi_variables can be overridden by subsequent <txp:variable /> entries if the same variable name is used
  • The adi_variables form can be manually edited and possibly altered so that the Variables admin tab can’t read it or ‘Admin’ variables become ‘Public’.
  • Reordering only works within “Admin” & “Public” variable groups

Let me know if you find any other problems.

Feedback

Comments are most welcome.

In the mood for love?

If you find this plugin useful, please consider donating to the Textpattern development team.

Last edited by gomedia (2016-06-08 03:01:47)

Offline

#2 2008-10-26 12:32:31

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Re: adi_variables - Manage TXP variables

Awesome. Thank you so much for this.

It’s like dream come true.

Last edited by FireFusion (2008-10-26 12:33:12)

Offline

#3 2008-10-26 21:08:04

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_variables - Manage TXP variables

FireFusion wrote:

Awesome. Thank you so much for this. It’s like dream come true.

My pleasure. I hope it lives up to your dreams. If it turns into a nightmare, let me know.

Offline

#4 2008-10-27 09:31:40

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: adi_variables - Manage TXP variables

maybe this question doesn’t belong here as it’s not specific to your plugin. but i’ve heard all about 4.0.7 supporting variables, but i don’t really know what that means. could you explain or give an example as to which variables can be set, or how one might use them?


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#5 2008-10-27 09:52:18

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_variables - Manage TXP variables

In their simplest form they can be used as site-wide constants. For example having:

<txp:variable name="phone" value="01234 5678" />

at the top of each web page means that you can then use:

<txp:variable name="phone" />

to render the phone number where ever you need it: forms, pages, articles. Then if the phone number has to be changed – you only have to do it in one place (in the form or page where you defined the variable’s value).

They can also be used as flags & counters just like you would in scripts or programs. And combined with 4.0.7’s “tags within tags” there’s a whole world of possibilities.

I’m sure there’s a good explanation of their use somewhere but I can’t find it for the moment, but try these anyway:

Lots of examples in the Textbook.

The forum thread where the idea was floated.

A strange interview.

Last edited by gomedia (2008-10-27 11:26:17)

Offline

#6 2008-10-27 11:02:57

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: adi_variables - Manage TXP variables

oooh, so they’re like sitewide custom fields! awesome!


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#7 2009-05-20 10:21:20

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Re: adi_variables - Manage TXP variables

I’ve found this plugin quite useful for helping the client to set template options to change the display of their site.

Making variables such as “news_panel_position” with a value of “left” and “number_of_articles” with a number value.

But the trouble is getting the instructions and possible options in without extra training. It would be cool to have a plugin that allowed you to give a full instruction and a drop down list (or text box) to set a variable for that option.

So on an extensions tab you could set the variable options and instructions for setting that varible.

Variable Name Instructions Type Values
news_display_type How to display news articles dropdown rotator,slider,timline,static list
news_pane_location Location of “Latest News” panel on homepage dropdown left,right,center
news_article_limit Number of news articles to display textbox

Then on a content tab you would see just the instructions with the possible options.

Instructions Values
How to display news articles rotator,slider,timline,static list
Location of “Latest News” panel on homepage left,right,center
Number of news articles to display textbox

Offline

#8 2009-05-20 10:49:17

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_variables - Manage TXP variables

FireFusion wrote:

I’ve found this plugin quite useful for helping the client to set template options to change the display of their site.

Making variables such as “news_panel_position” with a value of “left” and “number_of_articles” with a number value.

That’s a bit clever – I might steal that idea one day!

How about if I extend the latest adi_notes to provide footnotes in the Variables admin tab? It won’t be dropdown heaven but would be quick to supply & hopefully usable.

Offline

#9 2009-06-30 08:05:53

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Re: adi_variables - Manage TXP variables

This plugin doesn’t seem to work with the latest svn. I get the following output on the varibles tab…

Event: adi_variables_admin, Step: , Something: , Variable:
RAW FORM:

array (
  'Form' => '<txp:variable name="center-name" value="Center Name" />
<txp:variable name="your-area" value="Your Area" />
<txp:variable name="street-address" value="Street Address" />
<txp:variable name="locality" value="Locality" />
<txp:variable name="region" value="region" />
<txp:variable name="postal-code" value="Post Code" />
<txp:variable name="tel" value="Telephone number" />
<txp:variable name="email" value="Email" />',
)

LINE BY LINE:
Line 0. <txp:variable name="center-name" value="Center Name" />
Line 1. <txp:variable name="your-area" value="Your Area" />
Line 2. <txp:variable name="street-address" value="Street Address" />
Line 3. <txp:variable name="locality" value="Locality" />
Line 4. <txp:variable name="region" value="region" />
Line 5. <txp:variable name="postal-code" value="Post Code" />
Line 6. <txp:variable name="tel" value="Telephone number" />
Line 7. <txp:variable name="email" value="Email" />

ANALYSIS:
VAR (ADMIN): <txp:variable name="center-name" value="Center Name" />
VAR (ADMIN): <txp:variable name="your-area" value="Your Area" />
VAR (ADMIN): <txp:variable name="street-address" value="Street Address" />
VAR (ADMIN): <txp:variable name="locality" value="Locality" />
VAR (ADMIN): <txp:variable name="region" value="region" />
VAR (ADMIN): <txp:variable name="postal-code" value="Post Code" />
VAR (ADMIN): <txp:variable name="tel" value="Telephone number" />
VAR (ADMIN): <txp:variable name="email" value="Email" />

VARIABLES DATA:

array (
  'center-name' => 
  array (
    'value' => 'Center Name',
    'public' => false,
  ),
  'your-area' => 
  array (
    'value' => 'Your Area',
    'public' => false,
  ),
  'street-address' => 
  array (
    'value' => 'Street Address',
    'public' => false,
  ),
  'locality' => 
  array (
    'value' => 'Locality',
    'public' => false,
  ),
  'region' => 
  array (
    'value' => 'region',
    'public' => false,
  ),
  'postal-code' => 
  array (
    'value' => 'Post Code',
    'public' => false,
  ),
  'tel' => 
  array (
    'value' => 'Telephone number',
    'public' => false,
  ),
  'email' => 
  array (
    'value' => 'Email',
    'public' => false,
  ),

Offline

#10 2009-06-30 10:02:00

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_variables - Manage TXP variables

FireFusion wrote:

This plugin doesn’t seem to work with the latest svn. I get the following output on the varibles tab…

Works OK with r3195 – the most recent I have installed. Don’t even know what the output message is trying to tell us but because of the changes in the TXP SVN environment I can’t immediately upgrade to the latest. Bear with me …

Offline

#11 2009-08-06 02:56:50

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: adi_variables - Manage TXP variables

Wow! This plugin is great! I have a set of variables that I define for each site, and having an admin-side interface for those is splendid.

Would you be willing to add support for nested txp:tags? The only change needed would be to have the value string written and read from single quotes ('my value') instead of doubles ("my value").1

My usage for this is for site-wide constants, such as the following:

<txp:variable name="site_map-url" value='<txp:site_url />site-map/' />
<txp:variable name="site_contact-url" value='<txp:site_url />contact/' />

If I manually add these into the form, the admin interface throws php errors. This is an example of what you warned about above: “The adi_variables form can be manually edited and possibly altered so that the Variables admin tab can’t read it…”

Indeed:

Notice: Undefined offset: 3 in /path/to/textpattern/lib/txplib_misc.php(570) : eval()’d code on line 132

Notice: Undefined offset: 3 in /path/to/journaltalk.dev/textpattern/lib/txplib_misc.php(570) : eval()’d code on line 132

Thanks again!

1 The more challenging change would be to make it recognize txp:tags and select the appropriate quote enclosure, but that’s not essential for this to work.

Last edited by johnstephens (2009-08-06 03:18:41)

Offline

#12 2009-08-06 11:45:50

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_variables - Manage TXP variables

FireFusion wrote:

This plugin doesn’t seem to work with the latest svn. I get the following output on the varibles tab…

Seems to be OK in 4.2.0 RC (r3260) – with both Classic & Remora.

Offline

Board footer

Powered by FluxBB