Announcing GeeVar: A Global Variables Plugin
Posted: 15 February 2008 05:24 PM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  748
Joined  08-16-2003

I had a need for a plugin like this while working on a few client websites. I finally whipped this together today. Hopefully somebody else finds it useful.

Imagine this scenario: You have built an ExpressionEngine website for a client. Everything works great, but there’s a problem: the client needs to be able to change little pieces of relatively static text. You don’t want to let him into the templates because, well, he’ll screw them up. You don’t want to let him access global template variables for the same reason, and besides, those variables don’t have any formatting options. How can you allow the client to change data—such as the company’s address, or maybe even that “Welcome to our website” text on the homepage—quickly and easily?

GeeVar allows you to create global variables using the control panel’s publish and edit interface. In short, each variable is a weblog entry. That means you can have as many or as few as you need, and you can format each variable’s value however you like (e.g. “none”, XHTML, or even using something like Textile or a wysiwyg editor). The variables are retrieved without the extra processing weight of the Weblog Module. As a bonus, GeeVar’s variables are cached, so the plugin only accesses the database once per page load. Thus, you can use as many GeeVar tag pairs as you like, anywhere in your templates (or embedded templates) without fear of ramping up your query count. In addition, you can nest GeeVar variables, giving you the ability to store a company’s address in a variable like so

{geevar_company_name}
{geevar_company_street_address}
{geevar_company_citystatezip}
{geevar_telephone}
{geevar_fax}
{geevar_email}

and have it turn into

Wally's Widget World
1 Widget Way
Walla Walla, WA 11111
(555) 123-0987
(555) 123-0988
widgets@www.info

Sound like something you could use? Go try it out.

 Signature 

Pst… have you taken a look at Weever yet?

Profile
 
 
Posted: 20 February 2008 09:07 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  139
Joined  05-18-2004

very interesting Mr. Wilson. We’ll be giving this one a try for sure.  Thanks for sharing it.

 Signature 


EE Services & Migration • Blog Design Small Business Blogs & Websites • Site Development
Member of the EE Professional NetworkGet in touch today!

Profile
 
 
Posted: 21 February 2008 06:44 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  177
Joined  10-17-2007

Brilliant, that sounds like just what I was looking for. I’ll let you know how I get on with it.

Thank you

Profile
 
 
Posted: 21 February 2008 06:53 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  177
Joined  10-17-2007

Mr Wilson,
would the plugin still work if I add an extra field in the field group for a description of the variable?
This would just be information for the client when they are updating their varibales, ie to explain where the variable appears, or what sections of the site it affects.

Profile
 
 
Posted: 21 February 2008 09:27 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  748
Joined  08-16-2003

Yep, you can add anything extra you want. GeeVar just needs:

* An appropriately-prefixed URL title (i.e. geevar_my_variable)
* An appropriately-named value custom field (i.e. geevar_value)

It will also look at the custom field’s formatting.

GeeVar will ignore anything else. Field descriptions won’t hurt a thing. You could even add more custom fields if, for example, you wanted to access the data using exp:weblog:entries.

 Signature 

Pst… have you taken a look at Weever yet?

Profile
 
 
Posted: 27 February 2008 05:01 AM   [ Ignore ]   [ # 5 ]  
Research Assistant
RankRankRank
Total Posts:  545
Joined  01-05-2005

Hi, this does look really useful but we’re struggling to get it working.  We’ve followed the instructions in the docs but we can’t get anything to output.  It’s simply blank where the variable value should print.

If we turn PHP errors on we do get this error

Notice: Undefined variable: tagdata in /var/www/html/manage/plugins/pi.geevar.php on line 88

The server is running PHP5

 Signature 

Celebrating again soon.

Profile
 
 
Posted: 27 February 2008 09:05 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  748
Joined  08-16-2003

I ran into that error myself yesterday. I think I must have posted the wrong version of the file. Could you give the current download (1.0.2) a try?

 Signature 

Pst… have you taken a look at Weever yet?

Profile
 
 
Posted: 27 February 2008 12:43 PM   [ Ignore ]   [ # 7 ]  
Research Assistant
RankRankRank
Total Posts:  545
Joined  01-05-2005

Excellent…yep that sorted it.  Thanks!

 Signature 

Celebrating again soon.

Profile
 
 
Posted: 29 March 2008 03:48 PM   [ Ignore ]   [ # 8 ]  
Grad Student
Avatar
Rank
Total Posts:  43
Joined  08-18-2007

Is there any way to implement Geevar with stand alone entry form so that I can make an edit form outside of the control panel? Any links with pointers? raspberry

Thanks in advance.

P/S : Was trying out Geevar with the following code :

{exp:geevar weblog="wrs_globalvars" var_prefix="var_"}

                                {var_logged_in_welcome_message}

                        {
/exp:geevar}


With the following settings :

Weblog Full Name: WRS Global Variables
Weblog Short Name: wrs_globalvars
URL Title Prefix: var_

Field Order: 1
Field Label: Data
Field Name: var_
Field Type: WYSIWYG

But still, the outputs shows ”{var_logged_in_welcome_message}” in the browser. Any ideas?

 Signature 
Profile
 
 
Posted: 31 March 2008 09:56 AM   [ Ignore ]   [ # 9 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  748
Joined  08-16-2003

I’ll start with your P.S. ... Check the URL title of that entry. It should be “var_logged_in_welcome_message”. Is it? If not, there’s your problem.

As for getting Geevar to work with a stand-alone entry/edit form, it should work just like any other entry/edit form. Let me know if you run into any specific roadblocks.

 Signature 

Pst… have you taken a look at Weever yet?

Profile
 
 
Posted: 13 June 2008 07:14 PM   [ Ignore ]   [ # 10 ]  
Grad Student
Rank
Total Posts:  84
Joined  06-04-2006

Mr. Wilson:

I can’t get any output from the GeeVar plugin.

Here’s what I’ve got:

weblog: global
1 custom field: global_address
1 entry with url prefix: global_lvca_address
Formatting: textile. I’m also using the TEH extension, if that makes a difference.

template:

{exp:geevar weblog=“global”}
{global_lvca_address}
{/exp:geevar}

Output: {global_lvca_address}

Yes, the plugin is installed. What am I doing wrong?

Also tried it like this:

{exp:geevar weblog=“global” var_prefix=“global_” }
{global_lvca_address}
{/exp:geevar}

but still, no output.

 Signature 

Debra Weiss | drw Design

Profile
 
 
Posted: 16 June 2008 09:18 PM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  748
Joined  08-16-2003

GeeVar 1.0.4 has been posted. It now supports “meta” variables, such as status.

@jejuna: Can you download 1.0.4 and see if it fixes your problem? If not, do let me know. I haven’t tested with Textile and I’m not sure what the TEH extension is, so either of those could be the culprits.

 Signature 

Pst… have you taken a look at Weever yet?

Profile
 
 
Posted: 17 June 2008 03:13 PM   [ Ignore ]   [ # 12 ]  
Grad Student
Rank
Total Posts:  84
Joined  06-04-2006

I did download and install the new version, but still, no output.

It doesn’t seem to matter whether the text in the custom field is formatted as Textile, XHTML, or “none”, as I’m still getting no output.

I think I’ve done everything correctly:

1. Created a weblog called “global”.
2. Created a custom field called “global_address”.
3. Put text in field. Url title string is “global_lvca_address”

In the template:

{exp:geevar weblog=“global” var_prefix=“global_”}
{global_lvca_address}
{/exp:geevar}

Output: {global_lvca_address}

Note: If I call it from the standard weblog:entries tag, like so:

{exp:weblog:entries weblog=“global” entry_id=“2”}
{global_address}
{/exp:weblog:entries}

It outputs fine, but defeats the purpose of the plugin!

Am I missing something? Any ideas are appreciated!

 Signature 

Debra Weiss | drw Design

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 10:33 AM
Total Registered Members: 62686 Total Logged-in Users: 48
Total Topics: 77253 Total Anonymous Users: 37
Total Replies: 417021 Total Guests: 257
Total Posts: 494274    
Members ( View Memberlist )