Results 1 to 6 of 6

Thread: HOOK that executes AFTER inserttags have been replaced

  1. #1
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default HOOK that executes AFTER inserttags have been replaced

    I'm looking for access to the rendered Frontend Template page, AFTER the inserttags have been replaced. If the image_headline extension is to work fully, it must be able to replace text, AFTER the inserttags have been replaced. THEN only can I replace the text with images, otherwise, the replaced text not yet available for replacement. This also means that any modules or aricles that have been included using an inserttag {{insert_article::3}} will also not render and the content cannot be image headlined.

    The current HOOK doesn't work:
    Code:
    	$GLOBALS['TL_HOOKS']['outputFrontendTemplate'][] = array('ImageHeadline', 'replaceHeadlines');

  2. #2
    User Toflar's Avatar
    Join Date
    06-19-09.
    Location
    Lyss, Switzerland
    Posts
    170

    Default Re: HOOK that executes AFTER inserttags have been replaced

    Maybe a stupid idea, but what about using inheritance?

    Code:
    <?php
    class MyHookingClass extends Controller
    {
       protected function replaceInsertTags($strBuffer, $blnCache=false)
       {
          parent::replaceInsertTags($strBuffer, $blnCache=false);
          // do my code or provide another hook
       }
    }
    Regards

    Yanick - Contao core developer @terminal42 gmbh

  3. #3
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: HOOK that executes AFTER inserttags have been replaced

    Since the ONLY place the image_headline extension enters the TL/Contao code is via a hook and to make inheritence work, I'd need to have my HOOK class be an override for Controller.

    The easiest solution dawned on me -- which would not be an efficient solution and a duplication in Tl core code, but will work. Simply run replaceInsertTags through the output buffer before I start working on the output buffer. I'd just think that it would be quite simple for TL to just add a HOOK to access the buffer at the point AFTER replacing inserttags, at the page render view, e.g.

    My new HOOK would be outputFrontendPageContent (which would provide the page content after the page was run past "replaceInserttags"
    Code:
    $GLOBALS['TL_HOOKS']['outputPageContent'][] = array('ImageHeadline', 'replaceHeadlines');

  4. #4
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: HOOK that executes AFTER inserttags have been replaced

    I actually needed this same thing recently. For SEO purposes, I needed to replace all links to the home page with ones that don't refer to it by alias (i.e. http://mysite.com/home.html needed to become just http://mysite.com). And just found out (the hard way) that insert tags are replaced after this hook, so it missed a few.

    Just by reading the descriptions, it would seem that parseFrontendTemplate would fire before inserttags are replaced, and outputFrontendTemplate would fire after, but obviously this is not the case. If not, what's the difference between these two hooks?

    Do you know if anyone has requested this as a feature yet?

    Thanks!
    Brian

  5. #5
    User
    Join Date
    06-19-09.
    Posts
    417

    Default Re: HOOK that executes AFTER inserttags have been replaced

    Regarding SEO and removing home.html, you will find that this extension covers that, plus some other goodies:

    googlesitemap

    Prior to using this extension I was using a .htaccess RewriteRule that also worked quite well.

    Hope that is in some way helpful info ;-)

    Do you also force the use of www. ?

  6. #6
    New user
    Join Date
    04-11-10.
    Location
    France
    Posts
    4

    Default Re: HOOK that executes AFTER inserttags have been replaced

    Is there any solution for image_headline to replace font after the replaceInsertTags ??

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
  •