Question

I need to build a admin interface like this image show. In the past I use components for that purpose but now because the modules are generated trough admin-generator I don't know how to get this done. I check all this docs 1, 2, 3 but without any clue on how to do this. I also created a components.class.php under modules/sdriving_empresa/actions folder and include the component in the view include_component('sdriving_empresa') but get this error:

sfComponents initialization failed.

Any help?

Was it helpful?

Solution

Tabs and Partials, the easy way :)

One of the best possible javascripts for that purpose is Javascript Tabifier. Its easy to install and play with it. You will find a lot of other Javascript and jQuery Tabbers, get the one you most like.

I would advise you to learn everything about symfony 1 partials in order to get the job easily done. Usually partials are a piece of code which is saved in an external file, and does is loaded later in any part of your code. Its like a variable with a lot of html and php code. Partials (the external files) allow also to receive input variables, so its easy to send them ids from related modules or tables.

Lets look at an example with Tabifier with two Tabs, information and Admin and two partials

editSuccess.php

$sModuleName = sfContext::getInstance()->getModuleName();
$sbasepathtabs = $sModuleName . '/tabs';
<div class='tabber' id='tabberglobal1'>
    <div class='tabbertab' title='Information' >
        <?php
            include_partial($sbasepathtabs . '/_information/_information', array('form' => $form));
        ?>
    </div>

  <div class="tabbertab" title="Admin" >
    <?php
        include_partial($sbasepathtabs . '/_admin/_admin', array('form' => $form));
    ?>
  </div>
</div>

Easily setup it:

  1. Inside your module template folder, create the folder: /_tabs
  2. Inside the folder /_tabs create the folder /_information and /_admin
  3. Inside the folder /_tabs/_information create the file partial: _information.php
  4. Inside the folder /_tabs/_admin create the file partial: _admin.php

Inside each one of those files partials write anything you want.
Those partials will receive the left variable form: array('form' => $form).
You can send to the partials more than one variable: array('form' => $form, 'variable2' => $formnumber2)

When you write a partial, in example the partial _information, you can easily get the form object and its values in the template with:

$id = $form->getObject()->getId();

For normal variables you wont need to call getObject.

Finally, take a deep look at the documentation of both things, symfony partials and Javascript Tabifier. They will solve you anything you need.

Backend Admin Generator:

Admin generator automatically generates all templates in the cache folder. Example:

cache\backend\prod\modules\autoTbPrueba1Backend\templates
cache\backend\prod\modules\autoTbPrueba1Backend\templates\indexSuccess.php

Most of its files are already partials, pay attention to the files who has the _ symbol in their name, they are partials. This means that most of the work is already done for you, and the only thing you will have to do is to override some of the partials (TbPrueba1Backend/list_header which is the file _list_header.php) or even the full template (indexSuccess.php) with the extended information you need. In order to override backend generated templates and partials, you can copy those files to the template folder of your module:

apps\backend\modules\TbPrueba1Backend\templates
apps\backend\modules\TbPrueba1Backend\templates\indexSuccess.php

Set there any additional information you need, and if you dont see anything new while refreshing the web, remember to clear the symfony cache (symfony cc).

Once you have override the the templates and partials with the new information, the only thing you need now is to write/add those partials inside the div tabs created by your bootstrap framework as I described above.

For a good explanation of the admin generator:
Symfony 1.4 change admin generator actions or templates
http://www.slideshare.net/loalf/symfony-y-admin-generator
http://symfony.com/legacy/doc/jobeet/1_4/en/12?orm=Doctrine

OTHER TIPS

You need the moduleName and the componentName in your include_component()

function include_component($moduleName, $componentName, $vars = array())
{
  echo get_component($moduleName, $componentName, $vars);
}

Or maybe your module is in the wrong application. In that case, you may consider moving it in a plugin

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top