I wanted to create my own template for the admin-generator,
so I’ve followed a tutorial and i’m now making my own template based on the “admin” template.
But I defined a new variable called “rubrique” in the file “newAction” and when I tried to call it in the template “newSuccess.php” I obtained this error:
Notice: Undefined variable: rubrique in C:\wamp\www\PhpProject2\data\generator\sfDoctrineModule\immo\template\templates\newSuccess.php on line
-
newAction:
public function executeNew(sfWebRequest $request)
{
$this->rubrique =12;}
-
NewSuccess.php:
echo $rubrique;
ps: i’ve simplified the code
Does anybody have a solution?? sorry for my bad english :p
Sorry about the delay.
Okay… I think I might know your problem. I spent a chunk of time modifying the Admin Generator for a project, but that was over 1.5 years ago so I had to refresh my memory.
I’m taking an educated guess by saying you’re echoing your variable in
data\generator\sfDoctrineModule\immo\template\templates\newSuccess.phplike so:These files are actually compiled first and then executed. In the first pass the var
$rubriqueis not available. Try this instead:Note the square brackets. I think the files are run through a regex or str_replace or something; I can’t recall exactly.
Try this, then clear the cache
./symfony ccwhich is important. It should work now.Alternatively, override the template and put it in your module’s dir and use it with normal php tags.
Hope this helps 🙂
Edit:
You might know this already, but if you want to override the file as described above it will be available in the cache:
cache\frontend\dev\modules\{$MODULE_NAME}\templates\newAction.php, where{$MODULE_NAME}will be the name of your module prepended by the wordauto; e.g:autoUser.This overrides the cached version. Copy this into your module’s template dir and edit to your heart’s content.