collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 435
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

NEED HELP? If you're looking for support with Simple Portal, look no further than the Support Board!

Author Topic: Blocks in Blocks - Help needed to add block idea  (Read 25793 times)

0 Members and 1 Guest are viewing this topic.

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Blocks in Blocks - Help needed to add block idea
« on: March 10, 2015, 07:39:09 AM »
Hello everyone,
I hope you're all well :)

I was going to post in the blocks in blocks topic but thought this might be better in it's own as it could get quite complex..

I've an idea for a custom "blocks in blocks" I believe would be possible but am struggling to put together with my very limited knowledge :(

I'm basically looking to create a functional version of this:




The chat tab would show my shoutbox (shoutbox id = 2)
who's online tab - ..obvious (but limited to 200 in height, to keep the main block uniform size)
Recent Posts tab - & Unread tabs both to show "advanced" versions, like below:

I'm currently using this as a block for my recent post, ( I'd also really like for my smileys to parse which they don't currently using the below code: )

Code: [Select]
<?php

/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.6
*/

/* [SETUP WHAT YOU WANT HERE] */

$topics_posts 2; // TOPICS - 1 | MESSAGES - 2
$limit 100; // How many recent posts do you want to output?
$number 240; // How many characters do you want to output?
$exclude_boards = array(87931771); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters false// Do you need to show html special characters like Greek characters?

// Scroll Enable? Height and Speed?
$scrolling 2;       // ENABLE - 1 | DISABLE - 2
$speed 4;           // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height "200px";
$scrollbar 1;       // ENABLE - 1 | DISABLE - 2

// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';

/* [STOP!] - THIS IS THE END OF SETUP */

//Only code from now on ;)
global $smcFunc$scripturl$sourcedir$modSettings$user_info$settings$context;

// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}

// Let's grab some database results
if ($topics_posts == 1) {

if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method $exclude_boards;
$exclude_boards = array();
}

$posts_result $smcFunc['db_query']('''
   SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' 
. ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from'
) . '
   FROM {db_prefix}topics AS t
   LEFT JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
   LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
   LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
   LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
   ' 
. (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' 
$user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' 
$user_info['id'] . ')' '') . '     
   WHERE m.approved=1'   
. (empty($exclude_boards) ? '' '
AND b.id_board NOT IN ({array_int:exclude_boards})'
) . ' AND {query_see_board}
   ORDER BY t.id_last_msg DESC
   LIMIT ' 
$limit
array(
'exclude_boards' => empty($exclude_boards) ? '' $exclude_boards,
)   
   );
$posts = array();
while (
$row_posts $smcFunc['db_fetch_assoc']($posts_result))
{

      global 
$memberContext;
      
loadMemberData($row_posts['id_member_updated']);
      
loadMemberContext($row_posts['id_member_updated']);

   
$posts[] = array(
  'id' => $row_posts['id_member_updated'],
      
'username' => '<a style="color: ' $row_posts['online_color'] . ';" href="' $scripturl '?action=profile;u=' $row_posts['id_member_updated'] . '">' $row_posts['poster_name'] . '</a>',
      
'subject' => '<a style="font-weight: bold;" title="' $text['board'] . '&nbsp;' $row_posts['name'] .'" href="' $scripturl '?topic=' $row_posts['id_topic'] . '.msg' $row_posts['id_last_msg'] . ';topicseen#new">' $row_posts['subject'] . '</a>',
      
'body' => $row_posts['body'],
  'avatar' => $row_posts['avatar'] == '' $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' $row_posts['avatar']),
  'board' => $row_posts['name'], 
  'time' => timeformat($row_posts['poster_time']),
  'new' => !empty($row_posts['is_read'])
   );
}
$smcFunc['db_free_result']($posts_result);

} else {

if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method $exclude_boards;
$exclude_boards = array();
}

$posts_result $smcFunc['db_query']('''
   SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' 
. ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from'
) . '
   FROM {db_prefix}messages AS m
   LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
   LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
   LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
   ' 
. (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' 
$user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' 
$user_info['id'] . ')' '') . '   
   WHERE m.approved=1'   
. (empty($exclude_boards) ? '' '
AND b.id_board NOT IN ({array_int:exclude_boards})'
) . ' AND {query_see_board}
   ORDER BY m.id_msg DESC
   LIMIT ' 
$limit
array(
'exclude_boards' => empty($exclude_boards) ? '' $exclude_boards,
)   
   );
$posts = array();
while (
$row_posts $smcFunc['db_fetch_assoc']($posts_result))
{

      global 
$memberContext;
      
loadMemberData($row_posts['id_member']);
      
loadMemberContext($row_posts['id_member']);

   
$posts[] = array(
  'id' => $row_posts['id_member'],
      
'username' => '<a style="color: ' $row_posts['online_color'] . ';" href="' $scripturl '?action=profile;u=' $row_posts['id_member'] . '">' $row_posts['poster_name'] . '</a>',
      
'subject' => '<a style="font-weight: bold;" title="' $text['board'] . '&nbsp;' $row_posts['name'] .'" href="' $scripturl '?topic=' $row_posts['id_topic'] . '.msg' $row_posts['id_msg'] . ';topicseen#new">' $row_posts['subject'] . '</a>',
      
'body' => $row_posts['body'],
  'avatar' => $row_posts['avatar'] == '' $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' $row_posts['avatar']),
  'board' => $row_posts['name'],  
  'time' => timeformat($row_posts['poster_time']),
  'new' => !empty($row_posts['is_read'])
   );
}
$smcFunc['db_free_result']($posts_result);

}

//Finally the Output

//Scrolling xD
if ($scrolling == 1)
echo 
'<div style="overflow: hidden;"><marquee height=' $height ' behavior="scroll" direction="up" scrollamount="' $speed '" onmouseover="this.stop()" onmouseout="this.start()">';

if (
$scrollbar == 1)
echo 
'<div style="height:' $height '; overflow-y: scroll; overflow-x: hidden;">';

foreach (
$posts as $post) {

// Lets fix the BBCode bug and Strip the Text
$content1 str_replace("[""<"$post['body']);
$content2 str_replace("]"">"$content1); 
$content3 strip_tags($content2);
$preview substr ($content3,0,$number);

echo
'<table>
<tr>
<td style="width: 40px;">
<img src="' 
$post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
$post['subject'];

if (!$post['new'] && $context['user']['is_logged'])
echo '&nbsp;<img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="new" border="0" />';

echo '<br />
<small>' 
$text['who'] . '&nbsp;' $post['username'] . '&nbsp;|&nbsp;' $post['time'] .'</small>
</td>
</tr>
</table>'
;

if ($htmlspecialcharacters) {
echo htmlspecialchars($previewENT_NOQUOTES"UTF-8") . '...';
} else {
echo $preview '...';
}

echo 
'<hr />';
}
        
//Scrolling xD
if ($scrollbar == 1)
echo 
'</div>'

if (
$scrolling == 1)
echo 
'</marquee></div>';
?>


I've currently got this, that produces the basic's but would love to be able to get it all working as it should!

Code: [Select]
$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.
$blocks = array(
                   array(
'label' => 'Chat',
'type' => 'sp_shoutbox',
'parameters' => array('display' => 1),
),
array(
'label' => 'Who`s Online',
'type' => 'sp_whosonline',
'parameters' => array('display' => 1),
),
array(
'label' => 'Recent Posts',
'type' => 'sp_recent',
'parameters' => array('type' => 1, 'display' => 1),
),
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>';



A Million and one thanks to anyone who has a go at this!
I can't thank you enough :D

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: Blocks in Blocks - Help needed to add block idea
« Reply #1 on: March 11, 2015, 01:18:21 PM »
I'll buy someone a beer in exchange  :thumbsup:

Offline phantomm

  • Translator
  • *
  • Posts: 406
  • Gender: Male
  • Smile, tomorrow will be worse...
    • Polish ElkArte community
  • SMF Version: None
  • Elkarte Version: 1.0.5
Re: Blocks in Blocks - Help needed to add block idea
« Reply #2 on: March 15, 2015, 11:47:33 AM »
Remove:
Code: [Select]
$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.

Find:
Code: [Select]
'type' => 'sp_shoutbox',
'parameters' => array('display' => 1),
and replace it with:
Code: [Select]
'type' => 'sp_shoutbox',
'parameters' => array('display' => 1, 'shoutbox' => 3),

Don't forget to replace shoutbox ID (mine is 3).

As for smileys, try to find - there are two lines where you need to make this change:
Code: [Select]
$row_posts['body']and replace it with:
Code: [Select]
parse_bbc($row_posts['body'])

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: Blocks in Blocks - Help needed to add block idea
« Reply #3 on: March 16, 2015, 08:30:32 AM »
Ooh, Thank you very much for your help phantomm!

with your changes I am able to get the shoutbox working :D

Unfortunately the smileys code made the smileys appear as "..." but this could be to do with the way the block code already manipulates bbc code :S - I'm not sure

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: Blocks in Blocks - Help needed to add block idea
« Reply #4 on: March 16, 2015, 04:11:40 PM »
To my disbelief I have this block with even more working now! :D

Code I am using to produce my desired block:

Code: [Select]
global  $sourcedir;

$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('content' => file_get_contents($sourcedir . '/spcustomblock1.php')),
),
array(
'label' => 'Recent Topics',
'type' => 'sp_recent',
'parameters' => array('type' => 1, 'display' => 1),
),
array(
'label' => 'Unread Posts',
'type' => 'sp_php',
'parameters' => array('content' => file_get_contents($sourcedir . '/spcustomblock2.php')),
),
);

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>';


spcustomblock1(&2).php both contain the code I would have normally used in a custom php block and uploaded top my sources folder.

Hopefully this helps others in the future looking to do something similar! :)

Offline josh4596

  • Semi Newbie
  • *
  • Posts: 21
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: Blocks in Blocks - Help needed to add block idea
« Reply #5 on: March 25, 2015, 06:32:23 PM »
Any chance I could get your unread posts php code 420? Would really appreciate it, save me some time looking. Thanks in advance.
« Last Edit: March 25, 2015, 11:00:04 PM by josh4596 »

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: Blocks in Blocks - Help needed to add block idea
« Reply #6 on: March 26, 2015, 12:41:10 PM »
Any chance I could get your unread posts php code 420? Would really appreciate it, save me some time looking. Thanks in advance.

Find here and customise to your liking :)
http://simpleportal.net/index.php?topic=11774.0

Offline josh4596

  • Semi Newbie
  • *
  • Posts: 21
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: Blocks in Blocks - Help needed to add block idea
« Reply #7 on: March 27, 2015, 08:51:38 PM »
Derp... I should have just looked would have took 2 mins. Thanks 420.

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: Blocks in Blocks - Help needed to add block idea
« Reply #8 on: March 05, 2016, 02:14:01 PM »
A while ago I switched back to a single use block but have had an idea to reuse this old block idea again, but when I try putting everything together I get told I am not allowed a code database code in the block code?..

Am I missing something?



Block code:
Code: [Select]
global  $sourcedir;

$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('content' => file_get_contents($sourcedir . '/spcustomblock1.php')),
),
array(
'label' => 'Recent Topics',
'type' => 'sp_recent',
'parameters' => array('type' => 1, 'display' => 1),
),
array(
'label' => 'Unread Posts',
'type' => 'sp_php',
'parameters' => array('content' => file_get_contents($sourcedir . '/spcustomblock2.php')),
),
);

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>';

It previews fine but when I upload the custom .php files into my sources folder, the problems seem to start? (attached)

Not sure what I am doing different this time?

Any ideas?..


TY  :thumbsup:

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: Blocks in Blocks - Help needed to add block idea
« Reply #9 on: March 05, 2016, 02:17:44 PM »
Nevermind!

I missed the upload of the attachment for the Advanced Unread Posts block..

Sorry!  ;)

Offline ♦ Ninja ZX-10RR ♦

  • Spammer Hammer
  • Support
  • *
  • Posts: 1193
  • Gender: Male
  • Sniper Legends
    • Virtual Interactive Games Entertainment™
  • SMF Version: 2.0.13
  • SP Version: 2.3.6
  • Elkarte Version: 1.0.6
Re: Blocks in Blocks - Help needed to add block idea
« Reply #10 on: March 05, 2016, 03:10:28 PM »
"Butterflies" happens, don't worry :P
Have you tried SimplePortal Documentation before asking? ;)
F.A.Q.  English Support  |  Blocks Support
Fancy Feature idea ?!  |  Blocks Requests
Themes & Graphics

? My job! ?No PMs for support unless it's a paid request. Thank you! :)#OpIsis

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: Blocks in Blocks - Help needed to add block idea
« Reply #11 on: March 05, 2016, 04:14:07 PM »
Hmm..

I thought I had solved it but when I activated the block, it broke my menu again in my theme  :dead:

Offline ♦ Ninja ZX-10RR ♦

  • Spammer Hammer
  • Support
  • *
  • Posts: 1193
  • Gender: Male
  • Sniper Legends
    • Virtual Interactive Games Entertainment™
  • SMF Version: 2.0.13
  • SP Version: 2.3.6
  • Elkarte Version: 1.0.6
Re: Blocks in Blocks - Help needed to add block idea
« Reply #12 on: March 05, 2016, 04:41:33 PM »
Can you elaborate that a bit further? Broke... How?
Have you tried SimplePortal Documentation before asking? ;)
F.A.Q.  English Support  |  Blocks Support
Fancy Feature idea ?!  |  Blocks Requests
Themes & Graphics

? My job! ?No PMs for support unless it's a paid request. Thank you! :)#OpIsis

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: Blocks in Blocks - Help needed to add block idea
« Reply #13 on: March 05, 2016, 04:46:30 PM »
Same as last the last bug, my menu buttons became unresponsive..

To be honest as soon as I noticed it, I reverted it. So I've still to check my console for errors but my usual fix of looking for a call to a jquery library doesn't seem like it's going to be of much use this time..

Away from the computer at the moment but I'll try and get more details if any are visible soon

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: Blocks in Blocks - Help needed to add block idea
« Reply #14 on: March 06, 2016, 05:31:58 AM »
Okay,

So I managed to solve the menu bug by wrapping the auto-refresh .js part of the advanced unread posts block's code in the function() tag thing.. :P


My next issue I'm having is adding font-awesome icons, next to my tabs..

I've managed to get them there with a bit of css..
but when you change tab, they all disappear! :(

I think there is various ways of adding FA so maybe I've taken the wrong approach?..

Maybe another one you can help solve Ninja?

420connect.co.uk
smftest/smftest

for testing..



Update - Solved...  :thumbsup:


I think making a topic for something, sends me into overdrive of ideas :P
« Last Edit: March 06, 2016, 05:36:34 AM by 420connect »

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: Blocks in Blocks - Help needed to add block idea
« Reply #15 on: April 22, 2016, 02:59:24 PM »
Hey guys,

I had an idea to add another tab to my blocks in blocks.. block that would a admin/mod shoutbox.

I have the shoutbox in place and the permissions to show the shoutbox to only admin/mods BUT, I am stuck for how I would go about hiding the tab for everyone else..

Here's the code I'm using:

Code: [Select]
global  $sourcedir;
$block = !empty($block) ? $block : array();
$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' => 'Staff Chat',
'type' => 'sp_shoutbox',
'parameters' => array('display' => 1, 'shoutbox' => 4),
),
array(
'label' => 'Who`s Online',
'type' => 'sp_whosonline',
'parameters' => array('display' => 1),
),
array(
'label' => 'Recent Posts',
'type' => 'sp_php',
'parameters' => array('content' => file_get_contents($sourcedir . '/spcustomblock1.php')),
),
array(
'label' => 'Recent Topics',
'type' => 'sp_recent',
'parameters' => array('type' => 1, 'display' => 1),
),
array(
'label' => 'Unread Posts',
'type' => 'sp_php',
'parameters' => array('content' => file_get_contents($sourcedir . '/spcustomblock2.php')),
),
);

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>';


Many thanks as always if anyone has any ideas!