SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: Ahmad Rasyid Ismail on September 29, 2010, 01:07:18 PM

Title: How To Create A Block In Block?
Post by: Ahmad Rasyid Ismail on September 29, 2010, 01:07:18 PM
I want to create a block in block like the sample that are given here: http://simpleportal.net/index.php?topic=5332.0. specifically this sample: http://simpleportal.net/index.php?page=blocks_in_block_sample#sp_collapse_54

This sample create a button like menu where when we click the menu, the block will show another block content in it. The only thing is, the sample is only for recent topic and recent post.

How do I use the same code to show content for like block 10, block 12, block 13 and block 14? I want the menu to be clickable so that it changes to the respective block when its menu is clicked similar to the sample.
Title: Re: How To Create A Block In Block?
Post by: AngelinaBelle on September 29, 2010, 03:34:17 PM
You wish to have a block with tabs? Like the example whjzd recently asked about?
http://simpleportal.net/index.php?topic=6371.0 (http://simpleportal.net/index.php?topic=6371.0)
 
That user solved the problem using some javascript for making list elements appear and disappear, and calling things (blocks, ssi functions, whatever) from withing the list elements:
http://simpleportal.net/index.php?topic=6420.msg37127#lastPost (http://simpleportal.net/index.php?topic=6420.msg37127#lastPost)
 
wjhzd could probably tell you where to find instructions for setting up the tabs.
Title: Re: How To Create A Block In Block?
Post by: Ahmad Rasyid Ismail on October 01, 2010, 02:34:03 PM
Code: [Select]
echo'
    <div id="tabs">
         <ul>
            <li><a href="#tabs-1">First</a></li>
            <li><a href="#tabs-2">Second</a></li>
            <li><a href="#tabs-3">Third</a></li>
            <li><a href="#tabs-4">Fourth</a></li>
         </ul>
     <div id="tabs-1">
';
$block1 = current(getBlockInfo(10));  // Load block info
$block1['style'] = sportal_parse_style('explode', $block1['style'], true);  //Parse block style parameters.
template_block($block1); // Output the block.
 
          echo '</div>
         <div id="tabs-2">
';
$block2 = current(getBlockInfo(12));  // Load block info
$block2['style'] = sportal_parse_style('explode', $block2['style'], true);  //Parse block style parameters.
template_block($block2); // Output the block.
          echo '</div>
         <div id="tabs-3">
';
$block3 = current(getBlockInfo(13));  // Load block info
$block3['style'] = sportal_parse_style('explode', $block3['style'], true);  //Parse block style parameters.
template_block($block3); // Output the block.
          echo '</div>
         <div id="tabs-4">
';
$block4 = current(getBlockInfo(14));  // Load block info
$block4['style'] = sportal_parse_style('explode', $block4['style'], true);  //Parse block style parameters.
template_block($block4); // Output the block.
          echo '</div></div>
';

Is this code correct? I really don't know how to call a block in a block like this sample: http://simpleportal.net/index.php?page=blocks_in_block_sample#sp_collapse_54 and I have gone through your link. There is nothing there to show how to call blocks in block the like the sample.

Please show me the right code.
Title: Re: How To Create A Block In Block?
Post by: Ahmad Rasyid Ismail on October 01, 2010, 02:41:22 PM
Just now, I found that this is post yesterday in the Blocks in Block and this is supposed to be the simpler version:

Code: [Select]
$blocks = array(
   array(
      'label' => 'Recent Posts',
      'type' => 'sp_recent',
      'parameters' => array('display' => 1),
   ),
   array(
      'label' => 'Recent Topics',
      'type' => 'sp_recent',
      'parameters' => array('type' => 1, 'display' => 1),
   ),
   array(
      'label' => 'Top Posters',
      'type' => 'sp_topPoster',
      'parameters' => array(),
   ),
   array(
      'label' => 'Calendar',
      'type' => 'sp_calendar',
      'parameters' => array(),
   ),
);

global $txt;

$button_list = array();
foreach ($blocks as $id => $block)
{
   $txt['sp_bib_label_' . $id] = $block['label'];

   $button_list[] = array(
      'text' => 'sp_bib_label_' . $id,
      'image' => '',
      'lang' => true,
      'url' => '#sp_bib_' . $id . '" id="sp_bib_button_' . $id . '" onclick="sp_bib_change(' . $id . '); return false;',
   );
}

$button_list[0]['active'] = true;

echo '
<div style="overflow: auto;">
   ', template_button_strip($button_list), '
</div>';

foreach ($blocks as $id => $block)
{
   echo '
<div id="sp_bib_', $id, '"', $id != 0 ? ' style="display: none;"' : '', '>';

   $block['type']($block['parameters'], 0);

   echo '
</div>';
}

echo '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
   function sp_bib_change(id)
   {
      for (var i = 0; i < ', count($blocks), '; i++)
      {
         document.getElementById(\'sp_bib_\' + i).style.display = i == id ? \'\' : \'none\';
         document.getElementById(\'sp_bib_button_\' + i).className = \'button_strip_\' + i + (i == id ? \' active\' : \'\');
      }
   }
// ]]></script>';

Can you guide me on how to use this?
SimplePortal 2.3.8 © 2008-2024, SimplePortal