ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Create PHP-like variables?

September 02, 2009 4:30pm

Subscribe [2]
  • #1 / Sep 02, 2009 4:30pm

    MetaPaint

    1 posts

    I can’t seem to find any information about this either way…

    Is it possible to create new variables to use across a template in the same way I would with PHP?

    For instance:

    {if segment_1 == "dogs"}
    {variable = 1}
    
    {if:elseif segment_1 == "cats"}
    {variable = 2}
    
    {if:else}
    {variable = 3}
    {/if}
    
    img/design/background_{variable}.jpg

    I know I could probably just use {segment_1} in this example, but I want to be able to assign variables based on conditional statements in a number of places. 

    I tried using PHP within the conditionals and it doesn’t want to cooperate.

    Thanks!

  • #2 / Sep 02, 2009 4:37pm

    Ingmar

    29245 posts

    If you want to use PHP-style variables, you’ll have to resort to using PHP.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases