Code snippets for symfony 1.x

Navigation

Refine Tags

Snippets tagged "admin custom"

Including custom partials in admin generator pages

Here is a method i developed to include some custom partials at the end of the edit action of a module which adapts admin generator.

i just added this at the end of editSuccess.php file of my generator theme ($sf_data_dir/generator/sfPropelAdmin/<myCustomTheme>/templates/editSuccess.php)

[?php // include xtra partials ?]
<?php if ($this->getParameterValue('edit.partials')): ?>
<?php
$partials = $this->getParameterValue('edit.partials');
foreach( $partials as $partial => $vars ) : ?>
[?php include_partial('<?php echo $this->getModuleName() ?>/<?php echo $partial ?>', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?> <?php foreach ($vars as $var): ?> , '<?php echo $var ?>' => $<?php echo $var; endforeach; ?>)); ?]
<?php endforeach; ?>

then you just have to add the partials in the generator.yml like this :

edit:
  partials:
    partial1: [ var1a, var1b ]
    partial2: [ var2a, var2b ]

where var.. are the variables you want to include in each partial.

this can be easily made for list success also.

by Kostas Papadimitriou on 2007-01-08, tagged admin  custom  generator  include  partial  partials 
(2 comments)

How to create a custom admin generator theme ...

... without having trouble with your PEAR directory.

If you use the admin generator but don't like the generated html code, you either can use a custom css file to redo the style, or you have to copy the original theme from

/path/to/$PEAR/symfony/generator/sfPropelAdmin/default

and redo the html here. The problem with that technique is, that you have to manage this PEAR directory from now on, instead having the new theme located in your project folder. That's bad, because your theme will be lost if you clear your PEAR installation or decide to uninstall the symfony version and re-install another one.

After doing some research in the forums and docs, I tried to create the theme in my project directory, with the expected folder structure. I created a folder structure in my projects data dir, like this:

/path/to/$PEAR/data/generator/sfPropelAdmin/$THEME_NAME

I just copied all directories and files from the default sfPropelAdmin theme to this folder, but this didn't worked out. symfony wasn't able to find this theme. So, I created a symbolic link to this folder:

ln -s \
/path/to/$PROJECT_NAME/data/generator/sfPropelAdmin/$THEME_NAME \
/path/to/$PEAR/data/symfony/generator/sfPropelAdmin/$THEME_NAME

Now, you I modify the template to fit my needs, e.g. reset the css classes, add a new table structure and so on. After upgrading/uninstalling/installing a new copy of symfony, don't forget to check if the symbolic link still exists. If not, just re-create it, and everything should work.

If your webserver and php understoods the following of symbolic links (Windows doesn't), you can use this new theme for your sfPropelAdmin generated modules via the theme configuration handle in your generator.yml:

generator:
  class:              sfPropelAdminGenerator
  param:
    model_class:      ModelClass
    theme:            $THEME_NAME
by Pierre Minnieur on 2006-09-17, tagged admin  custom  generator  pear  theme 
(4 comments)