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

Whitespace, Plugin, EE 2.0, Variable set and Logic

Development and Programming

BPeddle's avatar
BPeddle
31 posts
16 years ago
BPeddle's avatar BPeddle

I am working on a plugin in EE2.0

It looks at the url and breaks it out and makes assumptions based on the data on the url segment. I then pass back a word:

try
{
    switch($this->_type)
    {
    case 'category':
        $this->return_data = trim($this->_type);
        break;
    case 'city':
        $this->return_data = 'city';
        break;
    case 'state':
        $this->return_data = 'state';
        break;
    default:
        throw new Exception('Invalid search type ' . $this->_type);
        break;
    }
}

...

In my template it starts with:

{preload_replace:controller="{exp:urlcheck}"}

If I output {controller} it displays the value I expect

I then want to test that value and based on it embed a specific template:

{if controller == "category"}
           {embed="/category"} 
      {if:elseif controller == "city"}
            {embed="/city"}  
      ...
      {/if}

It never seems to match. If I highlight the output of controller and paste it I will notice white space padded on the end. I tried to trim as you can see above but no luck.

Should I be able to test a preload_replace variable like I am, if not is there another solution?

Is this possibly a bug?

Thanks!

       
Ingmar's avatar
Ingmar
29,245 posts
16 years ago
Ingmar's avatar Ingmar

Let me move this thread to “Plugins” for you…

       
BPeddle's avatar
BPeddle
31 posts
16 years ago
BPeddle's avatar BPeddle

Oddly enough this conditional works

{if {controller} == category}

I would have assume category is a string and would need quotes.

       
BPeddle's avatar
BPeddle
31 posts
16 years ago
BPeddle's avatar BPeddle

Maybe not … getting errors on it now sporadically.

       

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.