collapse collapse

* Archive Notice

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.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 180
  • 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: How to add a scroll bar to a custom block?  (Read 7711 times)

0 Members and 1 Guest are viewing this topic.

Offline josh4596

  • Semi Newbie
  • *
  • Posts: 21
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
How to add a scroll bar to a custom block?
« on: April 07, 2015, 08:00:35 PM »
So this block is for Arantor's Levertine Gallery mod.

Code: [Select]
<?php
/**
 * @name Levertine Gallery
 * @copyright 2014-2015 Peter Spicer (levertine.com)
 * @license proprietary
 *
 * @version 1.0.3
 */

/**
 * This file provides the integration for SimplePortal.
 *
 * @package levgal
 * @since 1.0
 */

class LevGal_Portal_SimplePortal
{
public static function portal($parameters$id$return_parameters false)
{
if ($return_parameters)
{
return self::getParameters();
}
else
{
self::execute($parameters$id);
}
}

protected static function getParameters()
{
return array(
'type' => 'select',
'rows' => 'int',
'columns' => 'int',
);
}

protected static function execute($parameters$id)
{
global $txt$scripturl;

$type = !empty($parameters['type']) ? (int) $parameters['type'] : 0;
$rows = !empty($parameters['rows']) ? abs((int) $parameters['rows']) : 2;
$columns = !empty($parameters['columns']) ? abs((int) $parameters['columns']) : 6;
if (empty($rows))
{
$rows 2;
}
if (empty($columns))
{
$columns 6;
}

if (!allowedTo(array('lgal_view''lgal_manage')))
{
echo '
'
$txt['error_sp_no_pictures_found'];
return;
}

$qty $rows $columns;
switch ($type)
{
case 0:
default:
$itemList LevGal_Bootstrap::getModel('LevGal_Model_ItemList');
$items $itemList->getLatestItems($qty);
break;
case 1:
$itemList LevGal_Bootstrap::getModel('LevGal_Model_ItemList');
$items $itemList->getRandomItems($qty);
break;
}

if (empty($items))
{
echo '
'
$txt['error_sp_no_pictures_found'];
return;
}

echo '
<table class="sp_auto_align sp_levgal sp_levgal_'
$id'" style="width:100%;">';

$cellwidth floor(100 $columns);

$list array_keys($items);
for ($y 0$y $rows$y++)
{
if (empty($list[$y*$columns]))
{
continue;
}
echo '
<tr>'
;
for ($x 0$x $columns$x++)
{
$pos $y $columns $x;
if (empty($list[$pos]))
{
continue;
}
$item = &$items[$list[$pos]];
echo '
<td style="width:'
$cellwidth'%;">
<div class="sp_image smalltext">
<a href="'
$item['item_url'], '">'$item['item_name'], '</a><br />
<a href="'
$item['item_url'], '"><img src="'$item['thumbnail'], '" alt="'$item['item_name'], '" title="'$item['item_name'], '" /></a><br />
'
$txt['lgal_posted_by'], ' ', !empty($item['id_member']) ? '<a href="' $scripturl '?action=profile;u=' $item['id_member'] . '">' $item['poster_name'] . '</a>' $item['poster_name'], '<br />
'
$txt['lgal_posted_in'], ' <a href="'$item['album_url'], '">'$item['album_name'], '</a><br />
</div>
</td>'
;
}
echo '
</tr>'
;
}

echo '
</table>'
;
}

public function isPortalInstalled()
{
return LevGal_Helper_Database::matchTable('{db_prefix}sp_functions');
}

public function ensureInstalled()
{
global $smcFunc;

$request $smcFunc['db_query']('''
SELECT id_function
FROM {db_prefix}sp_functions
WHERE name = {string:sp_levgal}'
,
array(
'sp_levgal' => 'sp_levgal',
)
);
if ($smcFunc['db_num_rows']($request) == 0)
{
$smcFunc['db_insert']('',
'{db_prefix}sp_functions',
array('function_order' => 'int''name' => 'string'),
array(0'sp_levgal'),
array('id_function')
);
}
$smcFunc['db_free_result']($request);
}
}

?>

I tried adding height and max height everywhere I seen width but that doesn't seem to work. I'd like to have 2 rows shown and anything more than that hidden with a scrollbar able to be used. With a total of 4 rows, 6 columns. Thanks if anyone can help with this, like I said I tried myself but didn't have much luck. I asked Arantor for help to no avail. Thanks again

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: How to add a scroll bar to a custom block?
« Reply #1 on: April 07, 2015, 08:31:35 PM »
I asked Arantor for help to no avail.
He should help you instead since it's a paid mod.
Also, I kindly refuse to patch/edit his code given some bad crap he said at my back.
Best regards.
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 Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1351
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: How to add a scroll bar to a custom block?
« Reply #2 on: April 08, 2015, 07:12:04 PM »
josh4596,

  Since it is a paid application that I do not have access to, it would probably be best if I had access to your forum as an Admin to adjust the block code directly and test it at the same time. Also I have a feeling that once the block is under way you will most likely change your mind a bit on how it displays. I am willing to help you in this way which is up to you to allow me that access.

Let me know and send me a PM with the relevant info if you decide to go that route.

Regards.

Offline josh4596

  • Semi Newbie
  • *
  • Posts: 21
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: How to add a scroll bar to a custom block?
« Reply #3 on: April 08, 2015, 07:18:31 PM »
I asked Arantor for help to no avail.
He should help you instead since it's a paid mod.
Also, I kindly refuse to patch/edit his code given some bad crap he said at my back.
Best regards.

Right, but he doesn't even get around to bug fixes. The audio streaming doesn't work in firefox and I've been trying for nearly a month to get that fixed yet, still not fixed. Said it's because of work but he had 4 days off work this past week and didn't attempt to fix it at all. Felt like I'd have better luck coming here. Honestly if there were more/better options for streaming audio within a gallery in smf or ipb/vb I wouldn't even continue using it.

@Chen I pm'd you an admin login to my site. This code above is actually a file that builds the block into simple portal though, it's not a code put into a custom php block. Thanks if you're able to help.
« Last Edit: April 08, 2015, 07:20:49 PM by josh4596 »

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: How to add a scroll bar to a custom block?
« Reply #4 on: April 08, 2015, 08:24:12 PM »
So sad that recently he turned into a bad person IMHO. By the way I am sure that Chen Zhen will fix it :) thanks for that mate, I really cannot provide support in this specific case.
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 Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1351
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: How to add a scroll bar to a custom block?
« Reply #5 on: April 08, 2015, 08:40:00 PM »
josh4596,

I made a mod a while back that was a mp3 gallery. However I never got around to updating it as it will only work with mp3 files and uses flash for playing the music and upload/download. This means it will not work with most mobile devices however it does work well with laptops or towers (non-mobile) that have adobe flash installed. It is called premiumbeat but as I said it will not work with most mobile browsers since both Apple & Android no longer support Adobe flash.

  I will have a look tomorrow in the evening & get back to you.

Regards.

Offline josh4596

  • Semi Newbie
  • *
  • Posts: 21
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: How to add a scroll bar to a custom block?
« Reply #6 on: April 08, 2015, 10:19:47 PM »
Well I wasn't totally fair. There are a lot of other features I use. Just sucks that the main feature I use it for has been broken for my favorite browser since I got it. I did notice preamiumbeat but I like that the gallery can keep all the members music organized in once place. I did consider premiumbeat though good job on it.

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1351
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: How to add a scroll bar to a custom block?
« Reply #7 on: April 08, 2015, 10:38:00 PM »
josh4596,

That Levertine mod looks pretty good and Imo Arantor did a nice job thus far.
If I understand you correctly, he appears to have already given the ability to have the rows and columns adjusted.
As for displaying only 2 rows and having a way to hide what is below that (the other 2 rows since you want to display only 4 total), a simple block height adjustment will not work because of variable thumbnail heights therefore the block code itself will have to be adjusted.  I will come up with something that is a bit more aesthetic compared to a scroll bar. Leave it with me for a day or so & I will post an alternate block code solution for you.

Regards.





Offline josh4596

  • Semi Newbie
  • *
  • Posts: 21
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: How to add a scroll bar to a custom block?
« Reply #8 on: April 08, 2015, 10:45:26 PM »
Right I noticed that as I was uploading some icons so more than 2 rows would actually be taken up. I mostly wanted to just control the height, it didn't need to show 2 rows perfectly depending on thumbnail size. But if you want to take that on that'd be great.

Honestly didn't even realize you could change the block max height right within the editing interface, thought that was something that had to be done within the code

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1351
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: How to add a scroll bar to a custom block?
« Reply #9 on: April 08, 2015, 10:51:20 PM »
josh4596,

  Simple Portal is fairly flexible whereas it allows you to adjust each block's css attributes with specifics if necessary.
 
« Last Edit: April 08, 2015, 10:53:40 PM by Chen Zhen »

Offline josh4596

  • Semi Newbie
  • *
  • Posts: 21
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: How to add a scroll bar to a custom block?
« Reply #10 on: April 08, 2015, 11:20:32 PM »
josh4596,

  Simple Portal is fairly flexible whereas it allows you to adjust each block's css attributes with specifics if necessary.

Just tried adding the max-height to my blocksinblock and it worked perfectly. Thanks Chen! If you want to try to get that other code working I'd appreciate it but it's not necessary.

P.S would it be possible to show each row separately and how would I go about doing that? Considering integrating this with the easy slider so it can have pages instead of scrolling.
« Last Edit: April 09, 2015, 03:02:51 AM by josh4596 »

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: How to add a scroll bar to a custom block?
« Reply #11 on: April 09, 2015, 10:05:06 AM »
If you need more info about SP's css: http://simpleportal.net/index.php?topic=13732.0 this topic turned out to be even more efficient than the docs for that specific subject ;D It's definitely not the first time I link it.

That Levertine mod looks pretty good and Imo Arantor did a nice job thus far.
Sure he did, wasn't talking about his code before. :)
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 Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1351
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: How to add a scroll bar to a custom block?
« Reply #12 on: April 09, 2015, 10:57:31 PM »
josh4596,

File: ../Themes/default/languages/levgal_lng/LevGal-Portals.english.php

find:
Code: [Select]
$txt['sp_param_sp_levgal_type_options'] = 'Latest items|Random items';

replace with:
Code: [Select]
$txt['sp_param_sp_levgal_type_options'] = 'Latest items|Random items';
$txt['sp_param_sp_levgal_per_page'] = 'Number of rows per dynamic page';



File: ../Sources/levgal_src/Portal/SimplePortal.php

! Replace entire contents with the following:
Code: [Select]
<?php
/**
 * @name Levertine Gallery
 * @copyright 2014-2015 Peter Spicer (levertine.com)
 * @license proprietary
 *
 * @version 1.0.3
 */

/**
 * This file provides the integration for SimplePortal.
 *
 * @package levgal
 * @since 1.0
 */

class LevGal_Portal_SimplePortal
{
public static function portal($parameters$id$return_parameters false)
{
if ($return_parameters)
{
return self::getParameters();
}
else
{
self::execute($parameters$id);
}
}

protected static function getParameters()
{
return array(
'type' => 'select',
'rows' => 'int',
'columns' => 'int',
'per_page' => 'int',
);
}

protected static function execute($parameters$id)
{
global $txt$scripturl$context$settings;

$type = !empty($parameters['type']) ? (int) $parameters['type'] : 0;
$rows = !empty($parameters['rows']) ? abs((int) $parameters['rows']) : 0;
$columns = !empty($parameters['columns']) ? abs((int) $parameters['columns']) : 0;
$rowsPerPage = !empty($parameters['per_page']) ? abs((int) $parameters['per_page']) + 2;
if (empty($rows))
{
$rows 1;
}
if (empty($columns))
{
$columns 4;
}

if (!allowedTo(array('lgal_view''lgal_manage')))
{
echo '
'
$txt['error_sp_no_pictures_found'];
return;
}

$qty $rows $columns;
switch ($type)
{
case 0:
default:
$itemList LevGal_Bootstrap::getModel('LevGal_Model_ItemList');
$items $itemList->getLatestItems($qty);
break;
case 1:
$itemList LevGal_Bootstrap::getModel('LevGal_Model_ItemList');
$items $itemList->getRandomItems($qty);
break;
}

if (empty($items))
{
echo '
'
$txt['error_sp_no_pictures_found'];
return;
}

echo '
<table id="levgal_pages" class="sp_auto_align sp_levgal sp_levgal_'
$id'" style="width:100%;">';

$cellwidth floor(100 $columns);
$list array_keys($items);
for ($y 0$y $rows$y++)
{
if (empty($list[$y*$columns]))
{
continue;
}

echo '
<tr>
<td style="display: none;">&nbsp;</td>
</tr>
<tr>'
;
for ($x 0$x $columns$x++)
{
$pos $y $columns $x;
if (empty($list[$pos]))
{
continue;
}
$item = &$items[$list[$pos]];
echo '
<td style="width:'
$cellwidth'%;">
<div class="sp_image smalltext">
<a href="'
$item['item_url'], '">'$item['item_name'], '</a><br />
<a href="'
$item['item_url'], '"><img src="'$item['thumbnail'], '" alt="'$item['item_name'], '" title="'$item['item_name'], '" /></a><br />
'
$txt['lgal_posted_by'], ' ', !empty($item['id_member']) ? '<a href="' $scripturl '?action=profile;u=' $item['id_member'] . '">' $item['poster_name'] . '</a>' $item['poster_name'], '<br />
'
$txt['lgal_posted_in'], ' <a href="'$item['album_url'], '">'$item['album_name'], '</a><br />
</div>
</td>'
;
}
echo '
</tr>'
;
}

echo '
</table>
<div id="levgalNavPosition" class="centertext"></div>
<script type="text/javascript"><!--
var pager = new LevgalPager("levgal_pages", '
$rowsPerPage');
pager.init();
pager.showPageNav("pager", "levgalNavPosition");
pager.showPage(1);
//--></script>'
;
}

public function isPortalInstalled()
{
return LevGal_Helper_Database::matchTable('{db_prefix}sp_functions');
}

public function ensureInstalled()
{
global $smcFunc;

$request $smcFunc['db_query']('''
SELECT id_function
FROM {db_prefix}sp_functions
WHERE name = {string:sp_levgal}'
,
array(
'sp_levgal' => 'sp_levgal',
)
);
if ($smcFunc['db_num_rows']($request) == 0)
{
$smcFunc['db_insert']('',
'{db_prefix}sp_functions',
array('function_order' => 'int''name' => 'string'),
array(0'sp_levgal'),
array('id_function')
);
}
$smcFunc['db_free_result']($request);
}
}
?>




File: ../Themes/default/scripts/portal.js

find:
Code: [Select]
// This function is for SMF 2 RC2 and above.

replace with:
Code: [Select]
/*
 * This function provides the dynamic pagination for Levgal
 *
 * @package levgal
 * @since 1.1.1
 */
 
function LevgalPager(tableName, itemsPerPage) {
    this.tableName = tableName;
    this.itemsPerPage = itemsPerPage;
    this.currentPage = 1;
    this.pages = 0;
    this.inited = false;
   
    this.showRecords = function(from, to) {       
        var rows = document.getElementById(tableName).rows;
       
        for (var i = 1; i < rows.length; i++) {
            if (i < from || i > to) 
                rows[i].style.display = 'none';
            else
                rows[i].style.display = '';
        }
    }
   
    this.showPage = function(pageNumber) {
    if (! this.inited) {
    alert("not inited");
    return;
    }

        var oldPageAnchor = document.getElementById('pg'+this.currentPage);
        oldPageAnchor.style.color = "black";
        oldPageAnchor.innerHTML = oldPageAnchor.innerHTML.replace(/\[/g, "").replace(/\]/g, "");

        this.currentPage = pageNumber;
        var newPageAnchor = document.getElementById('pg'+this.currentPage);       
newPageAnchor.innerHTML = '[' + newPageAnchor.innerHTML + ']';
newPageAnchor.style.color = "green";

        var from = (pageNumber - 1) * itemsPerPage + 1;
        var to = from + itemsPerPage - 1;
        this.showRecords(from, to);
    }   
   
    this.prev = function() {
        if (this.currentPage > 1)
            this.showPage(this.currentPage - 1);
    }
   
    this.next = function() {
        if (this.currentPage < this.pages) {
            this.showPage(this.currentPage + 1);
        }
    }                       
   
    this.init = function() {
        var rows = document.getElementById(tableName).rows;
        var records = (rows.length - 1);
        this.pages = Math.ceil(records / itemsPerPage);
        this.inited = true;
    }

    this.showPageNav = function(pagerName, positionId) {
    if (! this.inited) {
    alert("not inited");
    return;
    }
    var element = document.getElementById(positionId);
   
    var pagerHtml = '<span onclick="' + pagerName + '.prev();"> &#171 Prev </span> | ';
        for (var page = 1; page <= this.pages; page++)
            pagerHtml += '<span id="pg' + page + '" onclick="' + pagerName + '.showPage(' + page + ');">' + page + '</span> | ';
        pagerHtml += '<span onclick="'+pagerName+'.next();"> Next &#187;</span>';           
       
        element.innerHTML = pagerHtml;
    }
}

// This function is for SMF 2 RC2 and above.



Within the Levgal SP block settings, enter the following attribute within the custom body style input:
Code: [Select]
overflow: hidden;



  Note: In some scenarios you may want the block height to be uniform for all the dynamic pages. To create that effect you simply add the height attribute to the custom body style input. This is not necessary but may be desired.

  This is just some fairly basic javascript that introduces dynamic pagination to the levgal SP block display.
Initially you will most likely need to clear your browser history/cache to have the page reload the portal's javascript file.

There will be a new heading in the Levgal portal block options which you need to configure.
With what you specifically requested the integer to enter will be 2

Regards.
 
« Last Edit: April 09, 2015, 11:10:44 PM by Chen Zhen »