We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Variables

Development and Programming

Yorick Peterse's avatar
Yorick Peterse
537 posts
15 years ago
Yorick Peterse's avatar Yorick Peterse

The variables plugin gives the possibility to create variables (either static or dynamic) and use them later on. This means that for example you can set certain data and use it in the head (if it’s embedded) without having to re-create a tag pair for the specific channel.

I wrote the plugin because I didn’t want to use an excessive amount of tags in order to retrieve specific data. For example, each blog entry on my website has a set of meta keywords and a meta description (stored in a custom field). The normal way to retrieve them is the create a new channel tag and fetch the meta data. This wasn’t something I was really looking forward to. First of all it makes the source code a mess and second it makes the system load slower (I’m a speed freak).

The solution? Write a plugin that stores certain data for usage later on. This is what Variables does. On my website I use Variables on pretty much every page in the main channel tag. For instance, on the blog index the code looks a bit like the following:

{exp:channel:entries channel="blog" orderby="date" sort="desc" limit="8" status="open" paginate="bottom" cache="yes" refresh="30" disable=”member_data|trackbacks|”}

{exp:variables:append name='meta_keywords' value='{meta_keywords}'}

{/exp:channel:entreis}

As you can see this is much easier than having to create another channel entries tag in the header template.

  • License: GNU GPLv3
  • Bitbucket page: https://bitbucket.org/YorickPeterse/ee-variables/
  • Download: https://bitbucket.org/YorickPeterse/ee-variables/get/tip.zip
       
Yorick Peterse's avatar
Yorick Peterse
537 posts
15 years ago
Yorick Peterse's avatar Yorick Peterse

Variables can now be found on Devot:ee : http://devot-ee.com/add-ons/variables/

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.