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: 471
  • 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]

Blocks speak! Do you have an interest in getting more blocks - or even making your own? The Blocks Board is for you!

Author Topic: Making a block a fixed width and side-by-side  (Read 5438 times)

0 Members and 2 Guests are viewing this topic.

Offline cralor

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Making a block a fixed width and side-by-side
« on: October 18, 2010, 07:58:20 PM »
    * SMF 2.0 RC3
    * SP 2.3.2
    * www.betahs.com
    * No errors.
    * I want to take middle block and cut it's width in half, so that I can have two blocks side-by-side. Is this possible, and how can I achieve this?

Thank you.

Here is a screenshot for better understanding :)


Offline deansmar

  • Full Member
  • ***
  • Posts: 122
  • Gender: Male
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Making a block a fixed width and side-by-side
« Reply #1 on: October 19, 2010, 04:42:52 AM »
the middle block as you call it, the width is the remainder of the width left over from the left and right block settings.

so if your total width is lets say 950px and you have allocated 200px for each sideblock then the middle block will be 550px

the best way to achieve what you would like would probably be the Block in Block work around.
here's a bit of information, hope it might help

http://simpleportal.net/index.php?topic=6561.msg37807#msg37807
http://simpleportal.net/index.php?topic=5332.0
http://simpleportal.net/index.php?page=blocks_in_block_sample#sp_collapse_54
as a foot note:
i went from a SMF 1.1.11 to SMF2 RC3 with out any problems what so ever, first of all de-install all Mods, converted to RC3, then installed SP2.3.2, then installed the required Mods.

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Making a block a fixed width and side-by-side
« Reply #2 on: October 19, 2010, 12:11:39 PM »
cralor, if I understand you, I think deansmar is correct.
 
There are several blocks-in-blocks approaches you could take. If you give one a try and come up with any questions, we'll try to answer them here.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline cralor

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Making a block a fixed width and side-by-side
« Reply #3 on: October 19, 2010, 08:44:03 PM »
Great! Thanks for the information. I tried searching, but never came up with results like this, so thanks for pointing them out!

I have decided that the JavaScript example will be the best choice in this case, rather than a 2 column block like I originally intended.

I am using this code:

Code: [Select]
global $txt;

$txt['recent_topics'] = 'Recent Topics'; // not used for now
$txt['recent_posts'] = 'Recent Posts';
$txt['recent_betas'] = 'Recent Betas';
$txt['recent_giveaways'] = 'Recent Giveaways';

$buttons = array(
    'recent_giveaways' => array(
      'text' => 'recent_giveaways',
      'image' => '',
      'lang' => true,
      'url' => '#recent_giveaways" id="b_rg" onclick="change_display(\'rb\'); return false;',
      'active' => true,
   ),
   'recent_betas' => array(
      'text' => 'recent_betas',
      'image' => '',
      'lang' => true,
      'url' => '#recent_betas" id="b_rb" onclick="change_display(\'rp\'); return false;',
   ),
   'recent_posts' => array(
      'text' => 'recent_posts',
      'image' => '',
      'lang' => true,
      'url' => '#recent_posts" id="b_rp" onclick="change_display(\'rg\'); return false;',
   ),
);

echo '
<div style="overflow: auto;">
   ', template_button_strip($buttons), '
</div>
<div id="recent_giveaways">
   ', sp_recent(array('type' => 1, 'display' => 1), 0), '
</div>
<div id="recent_betas" style="display: none;">
   ', sp_recent(array('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 == \'rg\' ? 1 : 0;

      document.getElementById(\'recent_giveaways\').style.display = current ? \'none\' : \'\';
      document.getElementById(\'recent_betas\').style.display = current ? \'\' : \'none\';
      document.getElementById(\'recent_posts\').style.display = current ? \'\' : \'none\';
      document.getElementById(\'b_rg\').className = current ? \'button_strip_recent_giveaways\' : \'button_strip_recent_giveaways active\';
      document.getElementById(\'b_rb\').className = current ? \'button_strip_recent_betas active\' : \'button_strip_recent_betas\';
      document.getElementById(\'b_rp\').className = current ? \'button_strip_recent_posts active\' : \'button_strip_recent_posts\';
   }
// ]]></script>';

I like the current functionality of 'recent_posts', but I'd like 'recent_betas' and 'recent_giveaways' to include posts from three separate boards each.

What would be the best way to accomplish this? Is it possible to gather data from three specific boards? Or maybe I should utilize the RSS feeds of each, merge them into a single RSS feed, and then somehow utilize that in the above script?

Thanks for your continued help!

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Making a block a fixed width and side-by-side
« Reply #4 on: October 20, 2010, 09:16:27 AM »
The key to all of this is the parameters you use in calling the function that displays the posts.
Code: [Select]
sp_recent(array('type' => 1, 'display' => 1), 0)How can we use all the options we can get when we use the block editor? We can look at the function and learn more.

function sp_recent($parameters$id$return_parameters false)
{
 global 
$txt$scripturl$settings$context$color_profile;
 
$block_parameters = array(
  
'boards' => 'boards',
  
'limit' => 'int',
  
'type' => 'select',
  
'display' => 'select',
 );
 if (
$return_parameters)
  return 
$block_parameters;
 
$boards = !empty($parameters['boards']) ? explode('|'$parameters['boards']) : null;
 
$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
 
$type 'ssi_recent' . (empty($parameters['type']) ? 'Posts' 'Topics');
 
$display = empty($parameters['display']) ? 'compact' 'full';
 
$items $type($limitnull$boards'array');

So you can see that the function is going to expect the array element $parameters['boards'] to be a string of board ids separated by a '|', that is going to be passed to ssi_recenttPosts or ssi_recentTopics (see those functions to see exactly how $boards is used). So you can choose which boards to use by calling sp_recent with, for example:
Code: [Select]
sp_recent(array('type' => 1, 'display' => 1, 'boards' => '1|10|4'), 0)
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline cralor

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Making a block a fixed width and side-by-side
« Reply #5 on: October 20, 2010, 01:02:48 PM »
Great!

Now, I'm having a little bit of an issue understanding how to modify the JS part to work with three different tabs.

Here it is what I have so far:
Code: [Select]
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
   function change_display(block)
   {
      var current = block == \'rg\' ? 1 : 0;

      document.getElementById(\'recent_giveaways\').style.display = current ? \'none\' : \'\' : \'\';
      document.getElementById(\'recent_betas\').style.display = current ? \'\' : \'none\' : \'\';
  document.getElementById(\'recent_posts\').style.display = current ? \'\' : \'\' : \'none\';
      document.getElementById(\'b_rg\').className = current ? \'button_strip_recent_giveaways\' : \'button_strip_recent_betas active\' : \'button_strip_recent_posts active\';
  document.getElementById(\'b_rb\').className = current ? \'button_strip_recent_giveaways active\' : \'button_strip_recent_betas\' : \'button_strip_recent_posts active\';
      document.getElementById(\'b_rp\').className = current ? \'button_strip_recent_giveaways active\' : \'button_strip_recent_betas active\' : \'button_strip_recent_posts\';
   }
// ]]></script>';

But it isn't working, however. What am I doing wrong?

Thank you!!

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Making a block a fixed width and side-by-side
« Reply #6 on: October 21, 2010, 09:51:39 AM »
The code you started with is very simple, and you need to make two kinds of changes to get it to do what you want.
 
1) To get posts from just one board, you need to specify the board in the call to sp_recent.
See the parameter list in sp_recent to see how to do this -- 'boards' => '1|2|3', for example.  'boards => '', if you want all boards.
 
2) The javascript conditional operator (or ternary operator) is not as mysterious as it looks http://www.w3schools.com/js/js_comparisons.asp, and it can still be useful in the javascript function if you use it appropriately.  But the function does need to be completely rewritten.  It's a two-state switch.  Instead, you need to be able to go through a list of several states.

---------------------------------
I just realized that you are not the first user to run into this problem.
So I thought about this a little bit.
I am not very good at typing the same thing over and over again correctly, so I made some arrays (php arrays and javascript arrays) to do that for me.
 
Code: [Select]
global $txt;
$things = array(
'rp' => array( 'txt'=>'recent_posts', 'title'=> 'Recent Posts', 'type' => 0, 'boards' =>'14', 'active' => true),
'rb' => array('txt'=>'recent_betas', 'title'=> 'Recent Betas', 'type' => 1, 'boards' =>'28', 'active' => false),
'rg' => array('txt'=>'recent_giveaways', 'title'=> 'Recent Giveaways', 'type' => 1, 'boards' =>'9', 'active' => false),
);
$bFix='b_'; // button prefix
$dIdFix='div_'; // prefix for div id, if needed for uniqueness
$buttons = array();
foreach ($things as $k => $thing)
{
  $button = $bFix . $k;
  $things[$k]['button'] = $button;
  $divid = $dIdfix . $thing['txt'];
  $things[$k]['divid'] = $divid;
 
  $txt[$thing['txt']] = $thing['title'];
 
  $buttons[$thing['txt']] = array (
         'text' => $thing['txt'],
         'image' => '',
         'lang' => true,
         'url' => '#' . $divid . '" id="' . $button . '" onclick="change_display(\'' . $k. '\'); return false;',
  );
  if  ($thing['active'] ) $buttons[$thing['txt']]['active'] = $thing['active'];
}
echo '
<div style="overflow: auto;" >
   ', template_button_strip($buttons), '
</div>';
foreach ($things as $k => $thing)
{
   echo '
<div id="', $thing['divid'] , '"', ($thing['active'] ? '' : ' style="display: none;"') , ' >
   ', sp_recent(array('type' => $thing['type'], 'display' => 1, 'boards' => $thing['boards']), 0), '
</div>
';
}
echo '<!-- tab flip script -->
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
     var things = new Array();
';     
   
$i = 0;
foreach ($things as $k => $thing)
{
      $i++;
      echo '
      things[', $i, ']= ["', $k, '", "', $thing['divid'], '", "', $thing['button'],'"];' ;
}
echo '
   function change_display(block)
   {
       var i;
       for ( i in things )
       {
           document.getElementById(things[i][1]).style.display = (block == things[i][0]) ? \'\' : \'none\';
           document.getElementById(things[i][2]).className = \'button_strip_\' + things[i][1] +
                                                               ((block == things[i][0]) ? \' active\' : \'\');
       }
   }
// ]]></script> ';
« Last Edit: October 21, 2010, 11:26:08 AM by AngelinaBelle »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline cralor

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Making a block a fixed width and side-by-side
« Reply #7 on: October 21, 2010, 07:10:23 PM »
Great!! Thanks so much!!!

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Making a block a fixed width and side-by-side
« Reply #8 on: October 21, 2010, 07:26:50 PM »
Of course, you need to choose the correct board ids...
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline cralor

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Making a block a fixed width and side-by-side
« Reply #9 on: October 21, 2010, 07:51:37 PM »
Of course, you need to choose the correct board ids...

Yep, I did :D

Offline Divecall

  • Full Member
  • ***
  • Posts: 201
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: Making a block a fixed width and side-by-side
« Reply #10 on: September 25, 2013, 07:49:06 PM »
It is possible to add two things:

1. display not recent posts or something, display Block-ID`d ?

2. It is possible to add an aout-rotator, that scrolls thru this ID`s like a slider, if the mouse-pointer is not over a menu?

thank you!

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Making a block a fixed width and side-by-side
« Reply #11 on: October 14, 2013, 04:33:29 PM »
Divecall,

I am not sure what you mean, so I cannot tell you if this is possible.
I am sure that, instead of doing all side-by-side, you could come up with some kind of marquee or tabbed interface.  But I am not sure I understand what you are looking for.

All this requires additional HTML, and so additional php
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?