Results 1 to 5 of 5

Thread: using replaceInsertTag hook

  1. #1
    User
    Join Date
    07-03-09.
    Posts
    31

    Default using replaceInsertTag hook

    A little question:

    My target is to add to efg extension one tag per field that i define in my Form.
    For example, i create my "book" form, with two fields: Title and Genre, and i store data in form data table.
    In one page of my site i list alla entries and when i click to details link i go in a new page. In this new page i want to use tags like {{form::Title}} and {{form::Genre}} because i want to use this data outside of the info_fd....tpl. [in the info....tpl template i have this data in this->.. (DCA Array)].
    I want to use this, for example to insert Title of the book in the <title></title> tags.

    So, i try to do it, i add in config.php (typolight/system/modules/efg/config) the hook "replaceInsertTags"


    thats point to one function implemented in typolight/system/modules/efg/ModuleFormdataListing.php.

    Code:
    $GLOBALS['TL_HOOKS']['replaceInsertTags'][] = array('ModuleFormdataListing', 'replaceInsertTagsTest');
    My function, in this first version, return "false" everytime is called.

    Code:
    	public function replaceInsertTagsTest($strTag)
    	{
    		return false;
    	}
    But when i try to see the page i've got this error:
    Recoverable error: Argument 1 passed to Module::__construct() must be an instance of Database_Result, none given, called in [MYPATH]/typolight/system/libraries/System.php on line 145 and defined in [MYPATH]typolight/system/modules/frontend/Module.php on line 71

    Can you tell me where is my mystake?
    Thanks boys.
    Tiziano

  2. #2
    Core developer
    Official Contao Team
    leo's Avatar
    Join Date
    06-04-09.
    Location
    Wuppertal, Germany
    Posts
    201

    Default Re: using replaceInsertTag hook

    You cannot put the hook into a Database class. You need to put it into a Controller class.

  3. #3
    User
    Join Date
    07-03-09.
    Posts
    31

    Default Re: using replaceInsertTag hook

    Thanks for the answer Leo..

    But if i put my my replaceInsertTags hook in Controller.php how can i access to "efg data details" that users select, in order to substitute {{form::title}} insert tags in the details page to the correct book's title?

    Probably my question is a newby question, i don't know...

    Thanks thanks thanks!
    Tiziano.

  4. #4
    User
    Join Date
    07-03-09.
    Posts
    31

    Default Re: using replaceInsertTag hook

    I can create a class that extends System or Controller, but i can't access to efg details array...
    Or i don't know how to do that...

  5. #5
    User
    Join Date
    07-03-09.
    Posts
    31

    Default Re: using replaceInsertTag hook

    One possible workaround is to get alias from url, by getting Environment vars of te System Object (so my class must extends System Class), and then by Database class (imported from System) retrive elements for this alias (that is unique)...

    But in this case i must performe two "SELECT...." for insert tags, and i think is not the best for the performance...

    Thanks.
    Tiziano.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •