Textpattern Forum

You are not logged in. Register | Login | Help

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

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 897
Website

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
  • an admin function to take a backup of the ‘adi_variables’ form

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.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)

Requirements

Tested in:

  • Textpattern 4.0.7+, PHP 5.2.4 – 5.2.9

adi_variables can be installed in pre-4.0.7 versions of Textpattern but obviously the variables can’t be used in your web pages.

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’.

Let me know if you find any other problems.

Feedback

Comments are most welcome.

Last edited by gomedia (2013-10-20 23:42:07)

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: 897
Website

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: 491
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: 897
Website

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: 491
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: 897
Website

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: 897
Website

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

Board footer

Powered by FluxBB