I’d like to do my own custom templates for Gii, but try as I might, I can’t seem to get Gii to find them, i.e., display them in the Code Template dropdown. Basically, I’ve tried adding this to backend\main\config:
'modules' => [
'gii' => [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'],
'generators' => [ //here
'crud' => [ // generator name
'class' => 'yii\gii\generators\crud\Generator', // generator class
'templates' => [ //setting for out templates
'lel' => 'L:xampp\htdocs\lel\\templates\crud\views', // template name => path to template
]
]
],
],
],
‘lel’ is the actual physical address of my custom gii templates. I’ve also tried changing the location to
'lel' => '@app\\templates\crud\views'
, and accessing gii through the backend URL, but that doesn’t work. I don’t get any errors. The templates just don’t show up in the dropdown. Does anyone have any ideas?
Actually, @app should get you there when using the backend url to get to gii and all the aliases ultimately map to physical addresses so that should have worked, but nonetheless, I copied the templates folder to my backend folder, inserted the following into backend/config/main.php,
'gii' => [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'],
'generators' => [ //here
'crud' => [ // generator name
'class' => 'yii\gii\generators\crud\Generator', // generator class
'templates' => [ //setting for out templates
'lel' => '@backend\templates\crud', // template name => path to template
]
]
],
],
Again, the slashes shouldn’t matter, but I tried forward slashes. That didn’t help either. It looks like you can’t add custom templates the way “The Book” says you can. It just doesn’t work.