Social > Team Blogs

Blocks In Blocks

<< < (18/18)

Divecall:
This here:

http://simpleportal.net/index.php?topic=5332.msg37856#msg37856

is no longer working with SP 2.3.5

 :dead:

[SiNaN]:
I'm very sorry for the extremely delayed response. Do you still require assistance with that?

FireDitto:

--- Quote from: [SiNaN] on April 27, 2010, 06:07:08 AM ---You can even call the block functions, without the block template, using the proper parameters. And with some JavaScript, you can have pretty blocks like this:

http://simpleportal.net/index.php?page=blocks_in_block_sample#sp_collapse_54


--- Code: ---global $txt;

$txt['recent_topics'] = 'Recent Topics';
$txt['recent_posts'] = 'Recent Posts';

$buttons = array(
   'recent_topics' => array(
      'text' => 'recent_topics',
      'image' => '',
      'lang' => true,
      'url' => '#recent_topics" id="b_rt" onclick="change_display(\'rp\'); return false;',
      'active' => true,
   ),
   'recent_posts' => array(
      'text' => 'recent_posts',
      'image' => '',
      'lang' => true,
      'url' => '#recent_posts" id="b_rp" onclick="change_display(\'rt\'); return false;',
   ),
);

echo '
<div style="overflow: auto;">
   ', template_button_strip($buttons), '
</div>
<div id="recent_topics">
   ', sp_recent(array('type' => 1, 'display' => 1), 0), '
</div>
<div id="recent_posts" style="display: none;">
   ', sp_recent(array('display' => 1), 0), '
</div>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
   function change_display(block)
   {
      var current = block == \'rt\' ? 1 : 0;

      document.getElementById(\'recent_topics\').style.display = current ? \'none\' : \'\';
      document.getElementById(\'recent_posts\').style.display = current ? \'\' : \'none\';
      document.getElementById(\'b_rt\').className = current ? \'button_strip_recent_topics\' : \'button_strip_recent_topics active\';
      document.getElementById(\'b_rp\').className = current ? \'button_strip_recent_posts active\' : \'button_strip_recent_posts\';
   }
// ]]></script>';
--- End code ---

So this is what I call "power of simplicity". I hope this gave a brief idea about how flexible and powerful SimplePortal is. If you have any questions, feel free to ask. ;)


There is also an alternative easier way explained here:

http://simpleportal.net/index.php?topic=5332.msg37841#msg37841

Edit: Fixed a minor issue with last block code.
Edit: disabled link to **** site

--- End quote ---

This is amazing; however, I can't seem to figure out how ot link to custom php blocks, as opposed to pre-made SP blocks?

This is the current code I'm using for my blocks, which also includes a piece to make sure the parent block only displays the inner blocks to the correct membergroups. I'd like to keep that aspect to it, as well, so that I can tab them all but not have X, Y or Z showing to the wrong membergroup.

This is just a regular block in block - how do I turn it into tabs?:

--- Code: ---$block_ids = array(34, 15, 20, 26, 106, 92, 102, 79, 83, 85);

$block_data = array();
foreach ($block_ids as $block)
{
   $data = current(getBlockInfo(false, $block, false, false, true));
   if (empty($data))
      continue;
   $block_data[$block] = $data;
   $block_data[$block]['style'] = sportal_parse_style('explode', $block_data[$block]['style'], true);
}

foreach ($block_data as $data)
echo '<div>', template_block($data), '</div>';
--- End code ---

Thank you for your time! :)

420connect:
Carrying off where others got stuck..

What is the correct code to call custom php blocks into the javascript version to work in tabs?

I've got this far but stuck calling the other block..


--- Code: ---$block['style'] = sportal_parse_style('explode', $block['style'], true);  //Parse block style parameters.
template_block($block); // Output the block.
$blocks = array(
                   array(
'label' => 'Chat',
'type' => 'sp_shoutbox',
'parameters' => array('display' => 1, 'shoutbox' => 2),
),
array(
'label' => 'Who`s Online',
'type' => 'sp_whosonline',
'parameters' => array('display' => 1),
),
array(
'label' => 'Recent Posts',
'type' => 'sp_php',
'parameters' => array( 'display' => 67),
),
array(
'label' => 'Unread Posts',
'type' => 'sp_recent',
'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>';
--- End code ---

But the Recent Posts isn't grabbing my custom block I'd like to use.. :(

ataru:
wow. great.

someone can tell me if it is possible to alter from container block some parameter of nested block(s)?

e.g. I have a custom php block where i open a shoutbox block named "Event #1 Chat".

I want to change that #1 with #n from custom block. where can i get the title of the block and change it before the output command?

Thanks


ok. found:


--- Code: ---$block['label']
--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version