This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » development » Documentation » How to get a value of the configuration file?
How to get a value of the configuration file? [message #100475] Sat, 05 June 2010 06:13 Go to next message
jstuardo  is currently offline jstuardo
Messages: 49
Registered: May 2010
Location: Santiago
Member
Hello... by using Doctrine I have created a categories backend. It works when using default templates coming with doctrine plugin. Now I want to customize the list_actions template, so I copied _list_actions.php from doctrine folder to apps/backend/modules/category/templates/. The problem is that in the _list_actions.php file there is this method call:

$this->configuration->getValue('list.actions')


When I run the page, this error occurs:


Notice: Undefined property: sfPartialView::$configuration in C:\WorkingFolder\Development\PHP\SouthernBulbs\apps\backend\ modules\category\templates\_list_actions.php on line 1

Fatal error: Call to a member function getValue() on a non-object in C:\WorkingFolder\Development\PHP\SouthernBulbs\apps\backend\ modules\category\templates\_list_actions.php on line 1

How can i do it?

Any help will be greatly appreciated

Thanks
Jaime


Symfony 1.4
Re: How to get a value of the configuration file? [message #100497 is a reply to message #100475 ] Sun, 06 June 2010 00:17 Go to previous messageGo to next message
rschumacher  is currently offline rschumacher
Messages: 162
Registered: August 2007
Location: Switzerland
Senior Member
Two questions come to my mind:
1. for verification: is your module "category" an admin generated module? In an admin generated module, the property $configuration should be known. In a CRUD module there is no $configuration, though.
2. did you copy the "_list_actions.php" file from from the Doctrine plugin templates directory, or from the cache folder that symfony generates? I usually do the latter when I need to override for special functionality.
Re: How to get a value of the configuration file? [message #100504 is a reply to message #100497 ] Sun, 06 June 2010 16:34 Go to previous messageGo to next message
jstuardo  is currently offline jstuardo
Messages: 49
Registered: May 2010
Location: Santiago
Member
Hello.... here are the answers:

1. I generated backend module automatically, using the tutorial in this page (which uses doctrine). That generated a folder called "category" inside apps/backend/modules. Inside it, it generated 4 folders: actions, config, lib and templates.

Almost all classes have no body, for example, actions.class.php contains only this:

<?php

require_once dirname(__FILE__).'/../lib/categoryGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/categoryGeneratorHelper.class.php';

/**
 * category actions.
 *
 * @package    SouthernBulbs
 * @subpackage category
 * @author     DESYTEC
 * @version    $Id$
 */
class categoryActions extends autoCategoryActions
{
}


The helper class has this:

<?php

/**
 * category module helper.
 *
 * @package    SouthernBulbs
 * @subpackage category
 * @author     DESYTEC
 * @version    $Id$
 */
class categoryGeneratorHelper extends BaseCategoryGeneratorHelper
{
  public function linkToNew($params)
  {
    return '<li class="add">'.link_to(__($params['label'], array(), 'sf_admin'), '@'.$this->getUrlForAction('new')).'</li>';
  }
}


2.- I copied the template from Doctrine template because otherwise, what will be the reason to have a generator.yml file?

In generator.yml these lines appears:

    config:
      list:
        title: Administración de Categorías
        display: [id, name, type, ordering, is_menu, is_published, created_at, updated_at, status]
        actions:
          _new: { label: Agregar }
        batch_actions:
          _delete: { label: Eliminar }


Look at the actions configuration. If I copied the template from cache folder, only this will be copied:

<?php echo $helper->linkToNew(array(  'label' => 'Agregar',  'params' =>   array(  ),  'class_suffix' => 'new',)) ?>


which will create the link to "new" action, in a hardcoded way. What if I add another action later?

Or maybe I have to modify the helper to add a new method that extracts the actions from the configuration file.

Thanks
Jaime


Symfony 1.4
Re: How to get a value of the configuration file? [message #100505 is a reply to message #100497 ] Sun, 06 June 2010 16:45 Go to previous message
jstuardo  is currently offline jstuardo
Messages: 49
Registered: May 2010
Location: Santiago
Member
Hello again.... I have deleted my local copy of _list_actions but this error appears now:

Notice: Undefined variable: helper in C:\WorkingFolder\Development\PHP\SouthernBulbs\cache\backend \dev\modules\autoCategory\templates\_list_actions.php on line 1

I deleted the cache and the same occurs. This worked before! Why $helper variable is not recognized now?

help!

Jaime


Symfony 1.4
Previous Topic:A todo list to check if your application is finished !
Next Topic:[?php notation in plugin folders?
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software