How to add some html/js code to pages via hooks

From aMember Pro Documentation
Revision as of 03:36, 9 August 2013 by Caesar (Talk | contribs)

Jump to: navigation, search

Add this code to site.php file:

Am_Di::getInstance()->hook->add(Am_Event::AFTER_RENDER, 'addTextAbove');
 
function addTextAbove(Am_Event_AfterRender $event)
{
    if (preg_match('#^/amember/helpdesk/index.*#i', $_SERVER['REQUEST_URI'])) //do it only for specific url
    {
        $event->replace('#(<h1>Tickets.*</h1>)#i', '$1<div>Some content</div>');
    }
}