1
hammondr
Rendering a block _inside_ a custom module
  • 2006/4/3 4:02

  • hammondr

  • Just popping in

  • Posts: 9

  • Since: 2005/9/15


Does anyone know how I can render a few blocks from one module inside a page in a custom module? Here's the scenario:

I have written a very simple custom module that has only one functional page: index.php. In this page, I want to display blocks from other modules embedded in the module body, rather than in the XOOPS left- or right-hand columns. In other words, I want to display the contents of some blocks inline, without relying on a XOOPS theme or the XOOPS admin->blocks to position blocks.

For example, I can place the following code in my module index.php to display a mini calendar from the extcal module:

require_once (XOOPS_ROOT_PATH.'/modules/extcal/blocks/extcal_blocks.php');

if (
$block b_extcal_minical_show ($options)) {
    
$GLOBALS['xoopsOption']['template_main'] = 'extcal_block_minical.html';
    
$xoopsTpl->assign('block'$block);
}


However, I can't do that again later in the same file, like so:
if ($block b_extcal_minical_show ($options)) {
    
$GLOBALS['xoopsOption']['template_main'] = 'extcal_block_upcoming.html';
    
$xoopsTpl->assign('block'$block);
}


My guess is that setting the 'template_main' key can only be done once per page. How can I modify my code to display more than one block?

2
hammondr
Re: Rendering a block _inside_ a custom module
  • 2006/4/3 4:26

  • hammondr

  • Just popping in

  • Posts: 9

  • Since: 2005/9/15


solution:
if ($block b_extcal_minical_show ($options)) {
    
$xoopsTpl->xoops_setCaching(0);
    
$xoopsTpl->assign('block'$block);
    
$xoopsTpl->display(XOOPS_ROOT_PATH."/modules/extcal/templates/blocks/extcal_block_minical.html") ;
}

<
snip>

if (
$block b_extcal_upcoming_show ($options)) {
    
$xoopsTpl->xoops_setCaching(0);
    
$xoopsTpl->assign('block'$block);
    
$xoopsTpl->display(XOOPS_ROOT_PATH."/modules/extcal/templates/blocks/extcal_block_upcoming.html") ;
}


This allows me to insert multiple blocks inline in single page.

Login

Who's Online

163 user(s) are online (83 user(s) are browsing Support Forums)


Members: 0


Guests: 163


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits