Difference between revisions of "How to add some html/js code to pages via hooks"

From aMember Pro Documentation
Jump to: navigation, search
(Created page with "Create /amember/application/configs/site.php with this code: <source> Am_Di::getInstance()->hook->add(Am_Event::AFTER_RENDER, 'addTextAbove'); function addTextAbove(Am_Event_Af...")
 
Line 1: Line 1:
Create /amember/application/configs/site.php with this code:  
+
Add this code to [[site.php file]]:
 
<source>
 
<source>
 
Am_Di::getInstance()->hook->add(Am_Event::AFTER_RENDER, 'addTextAbove');
 
Am_Di::getInstance()->hook->add(Am_Event::AFTER_RENDER, 'addTextAbove');

Revision as of 03:36, 9 August 2013

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>');
    }
}