Difference between revisions of "How to add/remove html blocks in member's area"

From aMember Pro Documentation
Jump to: navigation, search
Line 2: Line 2:
 
<source>
 
<source>
 
//add new block at position member/main/left
 
//add new block at position member/main/left
Am_Di::getInstance()->blocks->add(new Am_Block('member/main/left', 'My Block Title', 'my-block-id', null, 'renderMyBlock'));
+
Am_Di::getInstance()->blocks->add(new Am_Block('member/main/left', 'My Block Title', 'my-block-id', null, function (Am_View $v) {
 
+
function renderMyBlock() {
+
 
     $html = <<<CUT
 
     $html = <<<CUT
 
     <p>You can put some html code here</p>
 
     <p>You can put some html code here</p>
 
CUT;
 
CUT;
 
     return $html;
 
     return $html;
}
+
});
  
 
//remove block with id member-main-unsubscribe
 
//remove block with id member-main-unsubscribe
 
Am_Di::getInstance()->blocks->remove('member-main-unsubscribe');
 
Am_Di::getInstance()->blocks->remove('member-main-unsubscribe');
 
</source>
 
</source>

Revision as of 04:55, 5 February 2016

Add this code to site.php file:

//add new block at position member/main/left
Am_Di::getInstance()->blocks->add(new Am_Block('member/main/left', 'My Block Title', 'my-block-id', null, function (Am_View $v) {
    $html = <<<CUT
     <p>You can put some html code here</p>
CUT;
    return $html;
});
 
//remove block with id member-main-unsubscribe
Am_Di::getInstance()->blocks->remove('member-main-unsubscribe');