Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Director::addRules, undefined variable Action


3 Posts   511 Views


12 April 2012 at 11:20pm Community Member, 56 Posts

Hi all,

strange problem, when I use Director::addRules(50, array( ASSETS_DIR."/$Action" => "SomeActionController")); I get the notice: "Variable Action not defined.". However, I don't see how other _config.php files do define this 'variable'. Something I'm missing?



13 April 2012 at 8:36am Forum Moderator, 474 Posts

This is because you're using double quotes rather than single quotes. With double quotes, PHP tries variable substitution on the string. With single quotes, it leaves the string as is. (see [url][/url]).

Using Director::addRules(50, array( ASSETS_DIR.'/$Action' => "SomeActionController")); will work fine.


13 April 2012 at 9:33pm Community Member, 56 Posts

Very well, and also thanks for the link to the proper documentation from PHP! This indeed solved the problem for me.