SimplePortal
Social => Team Blogs => Topic started by: [SiNaN] on April 27, 2010, 06:07:08 AM
-
I have been meaning to make a blog post about how to display blocks in blocks with SimplePortal for some time but never got to it. Seeing as we just got a request for it (here (http://simpleportal.net/index.php?topic=5320.0)), I thought I would clarify it. Are we going to add such a feature in future SimplePortal versions? Nope, certainly not, never gonna happen.
Because it's already there! Actually it has been there since version 2.0.4. In case the idea is not clear for you, have a look at this sample page here:
http://simpleportal.net/index.php?page=blocks_in_block_sample (http://simpleportal.net/index.php?page=blocks_in_block_sample)
You'll see that there are 5 blocks in total, 4 of them embedded in a single block. This is quite easy to do with SimplePortal.
First: Create the blocks you want inside the other block. Be sure the box labelled Active is not checked. This will prevent the block from being displayed anywhere else on your site.
Second: find out the ids of the blocks you just created. You can find them by looking at the link to edit the block:
httx://someforum.com/index.php?action=admin;area=portalblocks;sa=edit;block_id=2;{session_var}={session_id}
What you need is the value of block_id (here it's 2). In the example below, I'll be using 49, 50, 52, 53 as the ids of blocks.
Third: create a Custom PHP block that does just what SimplePortal normally does with blocks. Here's a sample:
$block = current(getBlockInfo(false, 49, false, false)); // Load block info
$block['style'] = sportal_parse_style('explode', $block['style'], true); //Parse block style parameters.
template_block($block); // Output the block.
Line 1 loads the block with getBlockInfo(). Line 2 parses the block style. Line 3 finally uses that information to write it all out as HTML.
If you are putting more than one block inside your custom PHP block, you can use a table to control how they are arranged. So you can display blocks 49, 50, 52, and 53 in a custom php block like this:
$columns = 2;
$block_ids = array(49, 50, 52, 53);
$block_data = array();
foreach ($block_ids as $block)
{
$block_data[$block] = current(getBlockInfo(false, $block, false, false));
$block_data[$block]['style'] = sportal_parse_style('explode', $block_data[$block]['style'], true);
}
echo '
<table style="width: 100%;">
<tr>';
$counter = 0;
foreach ($block_data as $data)
{
if ($counter != 0 && $counter % $columns == 0)
{
echo '
</tr>
<tr>';
}
echo '
<td style="width: ', ceil((100 / $columns)), '%; vertical-align: top;">
', template_block($data), '
</td>';
$counter++;
}
echo '
</tr>
</table>';
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 (http://simpleportal.net/index.php?page=blocks_in_block_sample#sp_collapse_54)
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>';
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
-
Wow! Before I read this, I had not figured out how the blocks got called and wrapped in their formatting wrappers.
I had already seen a SimplePortal user calling a block on the fly (http://simpleportal.net/index.php?topic=5195.msg31460#msg31460 (http://simpleportal.net/index.php?topic=5195.msg31460#msg31460)) to put it in the page footer, LOL.
If the block already exists, though, this can be even easier.
-
Great "tutorial"!! Thanks Sinan!!
-
That's quite cool, Sinan. :)
-
Very nice tutorial, works great, thanks!
-
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.
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;',
),
);
<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>
and...
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\';
what am I doing wrong?
Thanks a lot!
-
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.
-
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
-
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>';
In short, you should add "limit => 10" parametres to sp_recent function.
-
Great stuff grafitus
Many thanks
-
Hi All
I have been playing with this for a few hours try to get top topics and top board in the block as well - making a total of four menu items
I can get the menu buttons okay but the rest has me beat
Is there any chance someone could give me the code
Many thanks in advance
Shortie
-
Now that, how can we add three tabs? (E.g: For recent boards x, y, z)
-
Extend the $buttons array
-
Extend the $buttons array
Of course, I know it. But JavaScript not working?
-
As soon as I try to make it a PHP block it shows a syntax error - thats with any of the code posted here...
-
As soon as I try to make it a PHP block it shows a syntax error - thats with any of the code posted here...
Which specific code are you trying to use? They all work on SP 2.3.2 and SMF 2 RC3 for me.
-
Second down in first post
$columns = 2;
$block_ids = array(49, 50, 52, 53);
$block_data = array();
foreach ($block_ids as $block)
{
$block_data[$block] = current(getBlockInfo(false, $block, false, false));
$block_data[$block]['style'] = sportal_parse_style('explode', $block_data[$block]['style'], true);
}
echo '
<table style="width: 100%;">
<tr>';
$counter = 0;
foreach ($block_data as $data)
{
if ($counter != 0 && $counter % $columns == 0)
{
echo '
</tr>
<tr>';
}
echo '
<td style="width: ', ceil((100 / $columns)), '%; vertical-align: top;">
', template_block($data), '
</td>';
$counter++;
}
echo '
</tr>
</table>';
But none of them are working for me; SimplePortal won't let me add the block due to a Syntax error. SMF 2.0 RC3, SP 2.3.2 - clean install.
-
You need to put a checkmark in Disable PHP Validation in the general settings of Simpleportal to get these scripts to work, at least that what I had to do or I would get the same issue of syntax error.
-
Hi,
I wanted to have two blocks side by side, however not in a parent block.
I tried this using the second bit of code, something like: $columns = 2;
$block_ids = array(24, 23);
$block_data = array();
foreach ($block_ids as $block)
{
$block_data[$block] = current(getBlockInfo(false, $block, false, false));
$block_data[$block]['style'] = sportal_parse_style('explode', $block_data[$block]['style'], true);
}
echo '
<table style="width: 100%;">
<tr>';
$counter = 0;
foreach ($block_data as $data)
{
if ($counter != 0 && $counter % $columns == 0)
{
echo '
</tr>
<tr>';
}
echo '
<td style="width: ', ceil((100 / $columns)), '%; vertical-align: top;">
', template_block($data), '
</td>';
$counter++;
}
echo '
</tr>
</table>';
Disabling the Title Class will just of course get rid of the title, but would still place the two blocks in the parent block, resulting in the Title's of the two child blocks to become smaller and not fit with the rest of the portal as I would like.
Anyway I could have two blocks side by side without it being inside of another block? or at least not look like it is?
-
Hello there,
from where I can get block ID no?
-
I've split a question from this thread and moved it to
http://simpleportal.net/index.php?msg=36356 (http://simpleportal.net/index.php?msg=36356)
-
I've noticed that the parent block that holds the split blocks always seems to have extra space at the bottom. The example has it as well. Is it possible to have the parent block snug the split blocks?
-
That extra space, created with a final "<br />", and part of all blocks, is found in template_block_core and template_block_curve.
Changing it would require a change to every block, unless you used a block-body strategy similar to the one I suggested in http://simpleportal.net/index.php?topic=6232.msg36445#msg36445 (http://simpleportal.net/index.php?topic=6232.msg36445#msg36445)
Here, perhaps, you would could use a custom class -- sp_no_bottom_break, for example -- in the custom body class field. If detected, you could choose to leave out the bottom break.
-
Thanks Angelina, i'll try that.
-
i'd like to use the javascript version of the blocks in blocks. i want to extend it so that i can have a shoutbox in there as well, but can't get the code right.
i can do the first version myself. thanks to simple, clear instructions. but the second doesn't explain how to add other blocks into the code, in addition to the code shown - which is no help to someone with no javascript knowledge... like me.
here's the original code (version 2)...
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>';
and here's my initial attempt (i get an error at the bottom of the page as well. see below the code)
global $txt;
$txt['recent_topics'] = 'Recent Topics';
$txt['recent_posts'] = 'Recent Posts';
$txt['volunteer_shoutbox'] = 'Volunteer Chat!';
$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;',
),
'volunteer_shoutbox' => array(
'text' => 'volunteer_shoutbox',
'image' => '',
'lang' => true,
'url' => '#volunteer_shoutbox" 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>
<div id="volunteer_shoutbox" 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(\'volunteer_shoutbox\').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_volunteer_shoutbox active\' : \'button_strip_volunteer_shoutbox\';
}
// ]]></script>';
and here's the error message:
Fatal error: Call to undefined function: () in /path/to/Sources/Load.php(2124) : eval()'d code on line 173
i would think it's an issue with the
document.getElementById(\'volunteer_shoutbox\').style.display = current ? \'\' : \'none\';
or
document.getElementById(\'b_rp\').className = current ? \'button_strip_volunteer_shoutbox active\' : \'button_strip_volunteer_shoutbox\';
but i don't know enough (by which i mean... anything..!) about javascript to do this myself.
but if someone can help me get this right, i should be able to add other stuff using this as a guide.
thanks :)
-
I guess that example was a bit difficult for some. Here's a more simple one:
$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>';
What you need to do with this one is; just modify the $blocks array as you like. I mean this one:
$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(),
),
);
"label" will be the block label, "type" is the block function, "parameters" is the array of block parameters.
That's all you need to do.
-
シナン YOU ARE THE BEST !!!
Full working !
GREAT.
I found thru the i-net a nice peace of code, that i want to add for the last topics section. You have an idea how to integrate this ?
this code is to long for to post here, so i attached here.
-
Really, that is the best code for SP ever. ! :applause: :applause: :applause:
(btw: the shoutbox is not working with this - but for me it is not necessary...)
-
I found thru the i-net a nice peace of code, that i want to add for the last topics section. You have an idea how to integrate this ?
this code is to long for to post here, so i attached here.
Make this change in the file you attached:
$ID_MEMBER = $context['user']['id'];
global $context, $settings, $scripturl, $txt, $db_prefix, $user_info, $modSettings, $user_profile, $smcFunc;
<?php
global $context, $settings, $scripturl, $txt, $db_prefix, $user_info, $modSettings, $user_profile, $smcFunc;
$ID_MEMBER = $context['user']['id'];
Save and upload it to Sources directory of your forum. Then at the end of the block code I gave above, add this:
function sp_custom_recent()
{
global $sourcedir;
require_once($sourcedir . '/recent post.php');
}
Then you can use 'sp_custom_recent' type in the $blocks array.
Really, that is the best code for SP ever. ! :applause: :applause: :applause:
(btw: the shoutbox is not working with this - but for me it is not necessary...)
Shoutbox will work. You need to pass a shoutbox id to parameters though, like in this example:
$blocks = array(
array(
'label' => 'Recent Posts',
'type' => 'sp_recent',
'parameters' => array('display' => 1),
),
array(
'label' => 'Shoutbox',
'type' => 'sp_shoutbox',
'parameters' => array('shoutbox_id' => 1),
),
);
-
GREAT !
I dont know, what i can write for to show you my happiness and for to show you my thankfulness.
T*H*A*N*K Y*O*U
-
@シナン :
It is possible to add two tabs more:
- Show unread post since last visit
- Show new replies to your post
?
Thank you in advance, CODEMASTER :thumbsup:
-
...and it is possible to add this nice hover/tooltip-effect from here ?
http://simpleportal.net/index.php?topic=1332.msg8762#msg8762 (http://simpleportal.net/index.php?topic=1332.msg8762#msg8762)
sound like the umltimate-SimplePortal-Block :D
Must be nice....
Any help is welcome !
-
Hi! :)
There are some guides in Spanish for this great modification.
Thx ;)!
-
@DaRKeN ask in the Spanish support board.
-
oK, sorry and thx :thumbsup:
-
Thanks so much for this tutorial! I have alway wanting to have more option for the layout of my frontpage... now it's there :) Thanks!
-
seriously when i read this i was so happy. just that i dont know how to code lol. but then again i understand how powerful and useful this thing is, now to find a way to learn how to use it :)
-
Am looking into this idea with a slight difference.
on my forum www.miltonkeynesaware.co.cc/mkaforum I am looking into making a block for the following.
Traffic Updates (image link to outside source),
Bus timetable (Image link),
Train timetable ( supplied widget),
Petrol prices (supplied widget).
How would I go about this as none of the information would be called from elsewhere within the forum itself.
-
I assume you mean you want a block with tabs to flip between your widgets.
You do it exactly the same way.
Except you can manage it without putting each widget in a block, if you like. At this point, you would not be using "blocks in blocks" at all, only php and javascript in your custom php block. Which would work just the same as it would on a standalone php page, since there is no connection to SMF at all.
-
Arvo All,
I just installed SP about 2 weeks ago and would like to confirm that I can do what I would like with this.
Currently I have RSS feeds from 2 different sites and would like to have it for about 4 or 5 sites. The problem is is that I don't want to make the page to long and also it seems to embed the RSS feed into the previous one if the page extends to far.
After looking at the sample it appears that I can label each site and have the tabs next to each other with one block. Am I reading this correctly ?
My site is www.thedallascowboysgang.com and if you look in the middle where the RSS feeds are you will be able to tell more about what I am talking about.
Thank you for you time.
-
Correct. Follow the example and start simple, and you should be able to manage this. IF you've written any code before, you'll know that you re likely to make lots of coding errors. So add only a few lines at a time to make it easier to narrow your errors down.
For support on working this through, please try the custom coding board.
-
Correct. Follow the example and start simple, and you should be able to manage this. IF you've written any code before, you'll know that you re likely to make lots of coding errors. So add only a few lines at a time to make it easier to narrow your errors down.
For support on working this through, please try the custom coding board.
Even Angelina,
Thank you for the quick response, if I have any problems I will seek support where you recommended.
Done coding before and have the grey hairs to prove it.. :'(
-
Hi guys,
Im using the 1st set of codes that [SiNaN posted. ok im using the 1st code & 2nd code.
my problem is there a 2 blocks inside 1, but the left hand side block has 6 post & right hand side block only has 2 post in it.
how can i set it up so there is an even amount on both sides.
-
all good worked it out
-
How to add custom-html-code in this "block-code"?
http://simpleportal.net/index.php?topic=5332.msg37841#msg37841
Thank's a lot...
-
I have split this question into a new topic:
Custom HTML in blocks-in-blocks (http://simpleportal.net/index.php?msg=49496)
-
Read thru all these and didn't see if there was a way to control the block size inside of the block.
Like I want to have two blocks in my block with one having 70% and the other having 30%
Is that possible?
-
Read thru all these and didn't see if there was a way to control the block size inside of the block.
Like I want to have two blocks in my block with one having 70% and the other having 30%
Is that possible?
I am also waiting for the solution
-
You could always lay out your blocks-in-blocks inside a table, and set the width of the table cells. That ought to work.
-
I guess that example was a bit difficult for some. Here's a more simple one:
$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>';
What you need to do with this one is; just modify the $blocks array as you like. I mean this one:
$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(),
),
);
"label" will be the block label, "type" is the block function, "parameters" is the array of block parameters.
That's all you need to do.
Hi, can some one help me with a small problem. How can i display simple ads ex: template_ad_position('below_menu'); in one of this blocs?
I do like this but is not working.
function sp_ads()
{
template_ad_position('below_menu');
}
array(
'label' => 'ads',
'type' => 'sp_ads',
'parameters' => array('display' => 1),
),
-
find the problem tnx any way
-
Hello.
I have been using the block with the recent topics and recent posts.
And I was wondering what code I could use to exclude forums or subforums from the recent threads or just specify certain forums or subforums.
I'm thinking about having "Recent Tropics/Threads" and another "recent" block for a specific subforum.
Thank you for your help in advance.
-
Hi :)
First, excuse my average english, it isn't my native langage and I hope you will understand me.
This topic was helpfull for me but I still have a problem. I need to add a rssfeed on my blocks, so I do this :
$blocks = array(
array(
'label' => 'News',
'type' => 'sp_BoardNews',
'parameters' => array(),
),
array(
'label' => 'Official News',
'type' => 'sp_rssfeed',
'parameters' => 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),
),
);
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>';
But I still have a problem, because I've got an Invalid Feed error on my front page. Did someone have a solution to this ?
-
For the newsfeed block, you will need to supply some parameters, including the feed.
So instead of
'parameters' => array(),
You want something like
'parameters' => array(
'url' => 'put url of your newsfeed here, in single quotes'
),
-
Thx a lot, it works fine :)
-
Glad to help! If you have any more questions, you can post them in the support boards.
Thanks!
-
Huhu, more I work, more question I have :P
So now, I have my rssfeed on my Tabs but, I need to have 10 news against of 5 at the moment. Which parameter should I put ?
Bonus Question : How did I increase Height's block ? I've got a Scroller on side and don't want it.
-
Hi,
The response on the french-support : http://simpleportal.net/index.php?topic=10635.msg54774#msg54774
your-forum/Sources/PortalBlocks.php
function sp_rssFeed (line 1944 about)
$count = !empty($parameters['count']) ? (int) $parameters['count'] : 5;
Change 5 for 10
Bonus Question : To change the height
your-forum/Themes/default/css/portal.css
Line 183 => /* Block specific styles */
Change 300px => increase the value.
.sp_rss_flow
{
max-height: 300px;
overflow: auto;
}
Sorry for my poor english
Greetings
-
is there anyway to change the coding so the blocks run horizontal.
$columns = 2;
$block_ids = array(49, 50, 52, 53);
$block_data = array();
foreach ($block_ids as $block)
{
$block_data[$block] = current(getBlockInfo(false, $block, false, false));
$block_data[$block]['style'] = sportal_parse_style('explode', $block_data[$block]['style'], true);
}
echo '
<table style="width: 100%;">
<tr>';
$counter = 0;
foreach ($block_data as $data)
{
if ($counter != 0 && $counter % $columns == 0)
{
echo '
</tr>
<tr>';
}
echo '
<td style="width: ', ceil((100 / $columns)), '%; vertical-align: top;">
', template_block($data), '
</td>';
$counter++;
}
echo '
</tr>
</table>';
-
Absolutely. Use HTML to set them up the way you want.
I recommend a nice tutorial site like w3schools.com to learn the HTML to lay out information the way you want it.
-
Thank you for this thread... because of the ability to put blocks in blocks I was able to set up my page much more efficiently...
One thing I did notice... some blocks are different sizes depending on the browser you are using. Look at the screen shots below. SCREENSHOT is from FF and SCREENSHOT2 is from Chrome... I'd aligned the 3 boxes within a box up in a row... looks great in Chrome... not quite so great in Firefox.... the funny thing is that the block on left and right are the SAME BLOCK but with two different settings set... yet only one seems to "shrink"?
-
I don't know what your HTML and CSS look like for these.
With some different width controls, you might get different results.
If you want some help on scripting, why not open up a new topic on the support or custom coding board?
Anyone who is available will try to lend a hand.
-
I don't know what your HTML and CSS look like for these.
With some different width controls, you might get different results.
If you want some help on scripting, why not open up a new topic on the support or custom coding board?
Anyone who is available will try to lend a hand.
Stock DEFAULT SMF theme ...
:)
What's it called? Curve?
-
I don't know what your HTML and CSS look like for these.
With some different width controls, you might get different results.
If you want some help on scripting, why not open up a new topic on the support or custom coding board?
Anyone who is available will try to lend a hand.
Stock DEFAULT SMF theme ...
:)
What's it called? Curve?
It's called "Curve" but in your files it will be labeled as "default".
-
I posted something in Bugs... with a comment that it probably wasn't strictly a bug :)
It seems that permissions for blocks inside other blocks don't work. Probably ignored as those blocks are set inactive anyway.
-
OK, I know this is an old thread, but it was a link given to me by a member on SMF. Finding the block ID is very confusing to me. I have NO coding experience and I don't understand any of this. Now I know you are going to tell me to learn, but that could take some time when all I need is this...I just need to know the block ID for the shout box so I can duplicate it on the portal. I did not understand the "file path" in the first post as to how to find it. I really need this in "stupid" talk because I just don't understand. A simple "click this, click that, click this would be great. I am using the most recent version of SP. I am so sorry to sound so dumb but I have only been doing this for 3 weeks. I understand how to edit the code I believe, I just need to know where to find the ID.
Thanks
-
I gave you example at sm.org :)
When you go to block settings you can see ID inside URL
for example:
/index.php?action=admin;area=portalblocks;sa=edit;block_id=15;f22f830=454d3f3e280abcb5aee69e15d09ff891
In my example block ID = 15
Click at icon (http://img402.imageshack.us/img402/7803/modifyr.png) related to this block and you'll get similar URL
-
I tried that. but I will look again. :0
-
but remember to go to blocks page, not Shoutbox :)
-
OH Duh...now I get it...man I feel stupid. I was looking for a notation of the ID in the page it's self...haha! Man I am such a newb
-
Great. it worked perfectly. Thanks for the help. I am learning as I go, but I am still very inexperienced
-
battling this for the last hour..
Want to add a custom php block, block_id 143, to the menu so that it has new posts, new topics, unread posts..
how the blazes do you tell the array to call teh block
$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' => 'Unread Posts',
'type' => 'sp_block',
'parameters' => array('block_id' => 143),
),
);
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>';
-
The simplest, easiest way maybe would be to make 3 blocks using the standard SMF blocks available... and perhaps a custom one from the custom blocks board if you need that.
"new posts, new topics, unread posts"
After you have made the 3 blocks (they should be set inactive) you simply put their block ID (all 3 of them) in the blocks in blocks code.
This code is in its own custom PHP block and just calls the others to display inside it using the IDs for them you provided.
You can select options to hide the titles and adjust the css of each sub block so that it looks like just one.
-
yeh, have the three blocks and set up, but i cant get the custom block to appear. Using the code i put above with the ref as sp_block and then block_id doesnt work for me.. :S
-
I think you are using the wrong piece of code. My site is working fine so you are doing something wrong.
Set the internal blocks to 'not active'. Check the viewing permissions on the main custom php block with the code below in it. Also it should be 'active', and the internal block IDs should be in the array.
In the block list in admin you can get their IDs from the links. Just put them in the $block_ids = array(49, 50, 52, 53);
Number of columns can be set there too.
$columns = 2;
$block_ids = array(49, 50, 52, 53);
$block_data = array();
foreach ($block_ids as $block)
{
$block_data[$block] = current(getBlockInfo(false, $block, false, false));
$block_data[$block]['style'] = sportal_parse_style('explode', $block_data[$block]['style'], true);
}
echo '
<table style="width: 100%;">
<tr>';
$counter = 0;
foreach ($block_data as $data)
{
if ($counter != 0 && $counter % $columns == 0)
{
echo '
</tr>
<tr>';
}
echo '
<td style="width: ', ceil((100 / $columns)), '%; vertical-align: top;">
', template_block($data), '
</td>';
$counter++;
}
echo '
</tr>
</table>';
-
Ah, theres a missunderstanding, thats not the kind of block im trying to create.
Trying to modify the example given earlier in this thread, (see screenshot)
I can add the extra menu item no problem, but i cannot get it to show the additional block using the code as below (block ref 143)
$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' => 'Unread Posts',
'type' => 'sp_block',
'parameters' => array('block_id' => 143),
),
);
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>';
-
I get as far as this...
The extra button added but i dont know how to call block 143 in teh array (the block is set as non-active)
-
I haven't used or tested that code - sorry I cant help with that. Hopefully someone else can.
But the way I described using the original blocks in blocks code will work - that is the easiest way I can see at the moment.
-
I'm using this code and I have the following error
There is a database error in your code. Please check it.
$columns = 3;
$block_ids = array(23, 22, 26, );
$block_data = array();
foreach ($block_ids as $block)
{
$block_data[$block] = current(getBlockInfo(false, $block, false, false));
$block_data[$block]['style'] = sportal_parse_style('explode', $block_data[$block]['style'], true);
}
echo '
<table style="width: 60%;">
<tr>';
$counter = 0;
foreach ($block_data as $data)
{
if ($counter != 0 && $counter % $columns == 0)
{
echo '
</tr>
<tr>';
}
echo '
<td style="width: ', ceil((100 / $columns)), '%; vertical-align: top;">
', template_block($data), '
</td>';
$counter++;
}
echo '
</tr>
</table>';
-
I get as far as this...
The extra button added but i dont know how to call block 143 in teh array (the block is set as non-active)
Are you trying to do this using the Unread Posts block from Here (http://simpleportal.net/index.php?topic=11774.0)?
-
Just what I was looking for, thankyou
-
I just want to confirm something with this one, the 'outta block' that you set other blocks in, this decides who can see them all? you cant set so differant member groups can see for example one block inside and another member group could see 2?
-
i want to add php custom block to block in block...
But not getting a way to do it.
My PHP code is (Planning to add smf info center in block in block)
global $context, $txt, $settings, $modSettings, $sourcedir, $user_info;
// Get the user online list.
require_once($sourcedir . '/Subs-MembersOnline.php');
$membersOnlineOptions = array(
'show_hidden' => allowedTo('moderate_forum'),
'sort' => 'log_time',
'reverse_sort' => true,
);
$context += getMembersOnlineStats($membersOnlineOptions);
$context['show_buddies'] = !empty($user_info['buddies']);
// Are we showing all membergroups on the board index?
if (!empty($settings['show_group_key']))
$context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array());
// Track most online statistics? (Subs-MembersOnline.php)
if (!empty($modSettings['trackStats']))
trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']);
// Retrieve the latests posts if the theme settings require it.
if (isset($settings['number_recent_posts']) && $settings['number_recent_posts'] > 1)
{
$latestPostOptions = array(
'number_posts' => $settings['number_recent_posts'],
);
$context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions));
}
$settings['display_recent_bar'] = !empty($settings['number_recent_posts']) ? $settings['number_recent_posts'] : 0;
$settings['show_member_bar'] &= allowedTo('view_mlist');
$context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']);
$context['show_member_list'] = allowedTo('view_mlist');
$context['show_who'] = allowedTo('who_view') && !empty($modSettings['who_enabled']);
// Show statistical style information...
if ($settings['show_stats_index'])
{
echo '
<div class="title_barIC">
<h4 class="titlebg">
<span class="ie6_header floatleft">
<a href="', $scripturl, '?action=stats"><img class="icon" src="', $settings['images_url'], '/icons/info.gif" alt="', $txt['forum_stats'], '" /></a>
', $txt['forum_stats'], '
</span>
</h4>
</div>
<p class="infobg2">
', $context['common_stats']['total_posts'], ' ', $txt['posts_made'], ' ', $txt['in'], ' ', $context['common_stats']['total_topics'], ' ', $txt['topics'], ' ', $txt['by'], ' ', $context['common_stats']['total_members'], ' ', $txt['members'], '. ', !empty($settings['show_latest_member']) ? $txt['latest_member'] . ': <strong> ' . $context['common_stats']['latest_member']['link'] . '</strong>' : '', '<br />
', (!empty($context['latest_post']) ? $txt['latest_post'] . ': <strong>"' . $context['latest_post']['link'] . '"</strong> ( ' . $context['latest_post']['time'] . ' )<br />' : ''), '
<a href="', $scripturl, '?action=recent">', $txt['recent_view'], '</a>', $context['show_stats'] ? '<br />
<a href="' . $scripturl . '?action=stats">' . $txt['more_stats'] . '</a>' : '', '
</p>';
}
// "Users online" - in order of activity.
echo '
<div class="title_barIC">
<h4 class="titlebg">
<span class="ie6_header floatleft">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who' . '">' : '', '<img class="icon" src="', $settings['images_url'], '/icons/online.gif', '" alt="', $txt['online_users'], '" />', $context['show_who'] ? '</a>' : '', '
', $txt['online_users'], '
</span>
</h4>
</div>
<div class="infobg2">
<p class="inline stats">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', comma_format($context['num_guests']), ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ' . comma_format($context['num_users_online']), ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'];
// Handle hidden users and buddies.
$bracketList = array();
if ($context['show_buddies'])
$bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
if (!empty($context['num_spiders']))
$bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
if (!empty($context['num_users_hidden']))
$bracketList[] = comma_format($context['num_users_hidden']) . ' ' . $txt['hidden'];
if (!empty($bracketList))
echo ' (' . implode(', ', $bracketList) . ')';
echo $context['show_who'] ? '</a>' : '', '
</p>
<p class="inline smalltext">';
// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online']))
{
echo '
', sprintf($txt['users_active'], $modSettings['lastActive']), ':<br />', implode(', ', $context['list_users_online']);
// Showing membergroups?
if (!empty($settings['show_group_key']) && !empty($context['membergroups']))
echo '
<br />[' . implode('] [', $context['membergroups']) . ']';
}
echo '
</p>
<p class="last smalltext">
', $txt['most_online_today'], ': <strong>', comma_format($modSettings['mostOnlineToday']), '</strong>.
', $txt['most_online_ever'], ': ', comma_format($modSettings['mostOnline']), ' (', timeformat($modSettings['mostDate']), ')
</p>
</div>';
// If they are logged in, but statistical information is off... show a personal message bar.
if ($context['user']['is_logged'] && !$settings['show_stats_index'])
{
echo '
<div class="title_barIC">
<h4 class="titlebg">
<span class="ie6_header floatleft">
', $context['allow_pm'] ? '<a href="' . $scripturl . '?action=pm">' : '', '<img class="icon" src="', $settings['images_url'], '/message_sm.gif" alt="', $txt['personal_message'], '" />', $context['allow_pm'] ? '</a>' : '', '
<span>', $txt['personal_message'], '</span>
</span>
</h4>
</div>
<p class="pminfo">
<strong><a href="', $scripturl, '?action=pm">', $txt['personal_message'], '</a></strong>
<span class="smalltext">
', $txt['you_have'], ' ', comma_format($context['user']['messages']), ' ', $context['user']['messages'] == 1 ? $txt['message_lowercase'] : $txt['msg_alert_messages'], '.... ', $txt['click'], ' <a href="', $scripturl, '?action=pm">', $txt['here'], '</a> ', $txt['to_view'], '
</span>
</p>';
}
echo '
</div>
</div></div>';
How to add above php code in block in block???
-
I would suggest putting that custom php code into a custom php block.
when you are satisfied with that, then explore using it inside another block.
-
If you are using the method explained in this (http://simpleportal.net/index.php?topic=5332.msg37841#msg37841) post, then you'll have to pass that whole code as the "content" parameter for sp_php block. However, it should be easier to do using the method explained at the very first post of this topic.
-
This here:
http://simpleportal.net/index.php?topic=5332.msg37856#msg37856
is no longer working with SP 2.3.5
:dead:
-
I'm very sorry for the extremely delayed response. Do you still require assistance with that?
-
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 (http://simpleportal.net/index.php?page=blocks_in_block_sample#sp_collapse_54)
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>';
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
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?:
$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>';
Thank you for your time! :)
-
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..
$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>';
But the Recent Posts isn't grabbing my custom block I'd like to use.. :(
-
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:
$block['label']