EllisLab text mark
Advanced Search
1 of 7
1
   
Fresh Variables
Posted: 21 November 2007 11:20 AM   [ Ignore ]
Avatar
Joined: 2002-06-03
6434 posts

Perhaps you’ve wanted global variables that you could use in tag parameters or conditionals, but do not have or desire to use FTP to create path.php global variables.  Or maybe path.php variables are fine, but you need them to hold ExpressionEngine tags or even PHP.  Or you need admins to have access to modify the variables, but don’t want them to have access to the templates.  Or maybe you are using MSM and would like some global variables to be installation-wide.  There are many uses, but this entry doesn’t need to get any more complicated than that, because the module is not a complicated one.  So, taste the freshness, and enjoy: Fresh Variables.

Make sure you read the instructions in the included instructions.html file!

 
Posted: 21 November 2007 11:46 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2002-02-05
462 posts

Very nice, looks like I can scrap that module from my ToDo list wink

Two things I noticed while trying this module:

1) it doesn’t have the look and feel of the other EE modules.
2) it overrides Template Global Variables.

First one isn’t really a problem, but to me it feels out of place (bit like a quick 3rd party mod)
Second is not a problem for me either, I tend to prefix globals with ‘global_’ anyway, but I can see some potential problems here.

Don’t get me wrong, I like it, great addition to the EE add-ons!

Cheers,
Elwin

 
Posted: 21 November 2007 01:42 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2002-06-03
6434 posts

1) Yes, it was a quick one-off, much like our other free first party add-ons that are not included with the application, hence the simple interface.  It actually began life as an extension only, so it was a simple extension settings form.  The need to allow some member groups access to it without giving them access to the Extension Manager, however, was reason enough to place its back end in the Modules section.

2) Yep, as do path.php global variables, which this emulates.  Both are intentional.

 
Posted: 21 November 2007 01:53 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2002-08-04
1830 posts

So Derek…I could use a field from a weblog (weblog:entries tag) as a variable, then use that variable as a parameter in a reverse-related entries tag? Can’t currently do that (well maybe with an embed) because of parse order, the related entries are parsed before the weblog:entries tag.

 
Posted: 21 November 2007 01:56 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2002-02-05
462 posts

Derek, thanks for clearing that up.

2) might be something to mention on the docs though.
Adding the module to an existing site that uses Template variables, and allowing the client to add “path” like variables that could override them sounds like a lot of fun smile

I can see many uses for this module, thanks again!

 
Posted: 21 November 2007 02:05 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2002-06-03
6434 posts

Randy: No, sorry.  Though I was thinking of you when I wrote this, something like that would require some modification of the base application or a specific extension of the weblog module.  I’ll keep it in mind for a rainy day, though.

Victor: Yes, these variables can be used in entries.  This however, doesn’t make any sense to me: {customvariable entry_id=“345”}.  What are you intimating would be accomplished by that syntax?

 
Posted: 21 November 2007 02:09 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2003-01-07
693 posts

You’re my hero Derek!

If this will do what I think it will. . . . yee ha!

 Signature 

learn more at eeSiteKit.com


NetRaising | a web services company


Custom Designed Dynamic Websites for Mission Driven Organizations

 
Posted: 21 November 2007 02:22 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2002-12-06
4241 posts

Hmmm….

Like when I’ve wanted to define a date formatting once and use that everywhere?

 Signature 

Get the missing EE2 owner’s manual - a complete guide to building an EE2 site.  It’s available in PDF or print.

 
Posted: 21 November 2007 02:32 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-26
1664 posts

Thanks, Derek. I was in the habit of putting the site keywords and description in global variables, but I didn’t like that someone had to have access to templates just to update those things if they wanted to. I’m sure I’ll find some clever usage for this!

 Signature 

ryan masuga
—————
Masuga Design | devot:ee
@masuga | @masugadesign | @devot_ee

 
Posted: 21 November 2007 02:38 PM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2002-06-03
6434 posts

Victor, you’re looking for a plugin or an extension, not a variable, as you are talking about multiple substitutions as well as processing that needs to occur.  Variables are simple replacements.  And oops, no, of course you can’t use it in weblog entries, I don’t know what I was thinking, except perhaps just wanting to say ‘yes!’ to every question.  Template global variables you can, but these variables are parsed much too early.

Like when I’ve wanted to define a date formatting once and use that everywhere?

Ayep.  And that’s an affirmative yes, unlike the misleading yes I gave Victor a few minutes ago.

 
Posted: 21 November 2007 03:08 PM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2002-06-03
6434 posts

No, they will remain dynamic.  If you turn on your Template Parsing Log, you will be able to see the order of things, as well as the list of your new variables, and where they are being parsed.

 
Posted: 21 November 2007 05:31 PM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2005-07-23
124 posts

Ye gods, man.

Merry Christmas to me!!

You just made standardized custom date formatting something I can actually enjoy!

Thank you, thank you, thank you,(ad infinitum)
Philip

 Signature 
 
Posted: 21 November 2007 06:01 PM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

Hi Derek and all!!

This sounds like a really great module but I think maybe my mind is missing the point somewhere along the line. It is probably just that I have never had the need for anything like this before but was wondering if someone could possibly post some real life examples of how and more importantly when you would use this module.

I just can’t seem to understand the reason for it at the moment but would love to see where it can be used.

Thanks.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 21 November 2007 06:04 PM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2006-01-23
559 posts

This is great Derek, thanks.  Is there any performance gain by using fresh variables instead of an embed, say for a header or a footer or is that not an appropriate use for it?

 
Posted: 21 November 2007 06:17 PM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Avatar
Joined: 2002-06-03
6434 posts

Mark:  Take Philip and Boyink’s example of a custom format string.  Let’s say you like your dates listed as %F %d, %Y  %h:%i %A.  You could set that to a variable called {date_format}, and then:

{entry_date format="{date_format}"

Or if you want to use a variable as a tag parameter.  {news_weblogs} could be a list of dozens of weblogs you have on a media site, and perhaps this list even changes or grows regularly.  All of your templates can benefit from this without having to update them as well by using:

{exp:weblog:entries weblog="{news_weblogs}"

fodney: There’s not going to be an appreciable difference, but there are differences. The main difference Fresh Variables have vs. User-Defined Template Variables in that instance is that they can be made installation wide in the Multiple Site Manager.  The main difference Fresh Variables have over embeds is that the content is actually placed into the template before most of the parsing occurs.  Embedded templates are each parsed on their own.  So a Fresh Variable could not be used to embed a weblog entries tag inside another, for instance, as it would be identical to nesting them in the same template.  The easiest way to think of Fresh Variables is to think of them exactly as you would path.php global variables, except they can hold complex HTML and Javascript, EE tags, and PHP if necessary.

 
Posted: 21 November 2007 06:31 PM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

Hi Derek,

Hmm still a little confused with this as I would just set the date format in the template myself but I can see that if you don’t want to allow access to the templates then this would be a good thing to enable. Problem being if someone puts something into the variable incorrectly then the site could stop working anyway. Ah well I suppose it’s down to the way you use it I guess.

With your second example I didn’t quite understand what you meant by it. How exactly would this help someone who doesn’t allow anyone else access to the back-end and wants to make things easier for themselves. For instance I have a couple of sites that only I ever access on the back-end so my question would be how and in what instances could this help me out at all?

Thanks.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
1 of 7
1