Social > Team Blogs

Blocks In Blocks

<< < (2/18) > >>

dannbass:
I'm puzzled, what if I want to add more... I thought I filled in the blanks, but it's not working... the tab appears, but the content is displayed in the second tab.

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

$txt['recent_topics'] = 'Temas';
$txt['recent_posts'] = 'Respuestas';
$txt['recent_audiciones'] = 'Audiciones';
 

$buttons = array(
   'recent_topics' => array(
      'text' => 'recent_topics',
      'image' => '',
      'lang' => true,
      'url' => '#recent_topics" id="b_rt" onclick="change_display(); return false;',
      'active' => true,
   ),
   'recent_posts' => array(
      'text' => 'recent_posts',
      'image' => '',
      'lang' => true,
      'url' => '#recent_posts" id="b_rp" onclick="change_display(); return false;',
   ),
   'recent_audiciones' => array(
      'text' => 'recent_audiciones',
      'image' => '',
      'lang' => true,
      'url' => '#recent_audiciones" id="b_ra" onclick="change_display(); return false;',
   ),
);
--- End code ---


--- Code: ---<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>
<div id="recent_audiciones" style="display: none;">
something here
</div>
--- End code ---
and...

--- Code: --- document.getElementById(\'recent_topics\').style.display = current ? \'none\' : \'\';
      document.getElementById(\'recent_posts\').style.display = current ? \'\' : \'none\';
  document.getElementById(\'recent_audiciones\').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\';
  document.getElementById(\'b_ra\').className = current ? \'button_strip_recent_audiciones active\' : \'button_strip_recent_audiciones\';
--- End code ---

what am I doing wrong?
Thanks a lot!

AngelinaBelle:
What happens if the viewer does not have permission to see one of the blocks? Which of the functions (getBlockInfo, sportal_parse_style, template_block) withholds its output? What's the easiest way to detect it?
 
-----------------
Oh -- I get it.  If empty($data['type']), then you might as well skip the template_block step -- you don't have anything for output, and you'll get an error.
 
 

Shortie:
Hi There

I have the recent topics and recent post block working great just as mentioned in the first post

My question is how can I cchange the number of items displayed to say 10

Many thanks

grafitus:

--- 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, 'limit' => 10), 0), '
</div>
<div id="recent_posts" style="display: none;">
   ', sp_recent(array('display' => 1, 'limit' => 10), 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 ---

In short, you should add "limit => 10" parametres to sp_recent function.

Shortie:
Great stuff grafitus

Many thanks

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version