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: 462
  • 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: BoardNews block and pagination question  (Read 17096 times)

0 Members and 1 Guest are viewing this topic.

Offline Mick.

  • Comrade
  • *
  • Posts: 77
  • Gender: Male
  • Premium SMF Themes
    • idesignSMF
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: BoardNews block and pagination question
« Reply #20 on: August 06, 2013, 11:27:56 AM »
Awseome, Thank you.  Got your PM, looking into it.

 Thanx.
Mick.

Offline sub5

  • Semi Newbie
  • *
  • Posts: 25
    • All student forum
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: BoardNews block and pagination question
« Reply #21 on: February 15, 2015, 07:28:24 AM »
Code: [Select]
global $context;

// Adjust your specific parameters
// when/if using the pagination for other blocks on the same page, remember to increment the formId
$parameters['boards'] = 1;
$parameters['limit'] = 50;
$parameters['perPage'] = 5;
$parameters['display'] = 'full';
$parameters['bodyStyle'] = 'windowbg';
$parameters['formId'] = 1;

// Do not bother altering the rest of the code...
$context['current_page' . $parameters['formId']] = !empty($context['current_page' . $parameters['formId']]) ? (int)$context['current_page' . $parameters['formId']] : 1;
$context['current_page' . $parameters['formId']] = (!empty($_REQUEST['current_page' . $parameters['formId']]) ? (int)$_REQUEST['current_page' . $parameters['formId']]-1 : $context['current_page' . $parameters['formId']] - 1);
customRecent($parameters);

function custom_pagination($content, $count=20, $id=1)
{
/* PHP pagination - max 7 visible integers and 6 periods (all links) - current page encircled with square brackets
* This php pagination code was developed by Underdog copyright 2013
* http://webdevelop.comli.com
* Licensed under the GNU Public License: http://www.gnu.org/licenses/gpl.html
*/

// This particular function is only used when opting an entire table else it is not necessary
global $context;

/*  Set the $context variables for the display template  */
$context['current_count' . $id] = count($content);
$context['current_pages' . $id] = (($context['current_count' . $id]) / $count) + 1;

if (count($content) <= $count || $count < 2)
{
$context['current_pages' . $id] = 0;
return $content;
}

if (($context['current_count' . $id] / $count) == (int)($context['current_count' . $id] / $count))
$context['current_pages' . $id] = ($context['current_count' . $id] / $count);

$context['current_showResults' . $id] = array(((int)$context['current_page' . $id] * $count), (((int)$context['current_page' . $id] + 1) * $count) - 1);
       



if ((int)$context['current_page' . $id]+1 == (int)$context['current_pages' . $id])
    $context['current_showResults' . $id][1] = count($content);
else
    $context['current_showResults' . $id][1] = (int)$context['current_page' . $id]*$count + ($count-1);
   
foreach($content as $key => $var)
{
if ((int)$key >= (int)$context['current_showResults' . $id][0] && (int)$key <= (int)$context['current_showResults' . $id][1])
$new_content[] = $var;
}

if (!empty($new_content))
$context['current_showResults' . $id][1] = ((int)$context['current_page' . $id]*$count) + count($new_content);
else
$new_content = $content;

return $new_content;
}

function custom_pages($lang, $anchor, $link, $pages, $sort=false, $order=false, $id=1, $style='windowbg')
{
/* PHP pagination - max 7 visible integers and 6 periods (all links) - current page encircled with square brackets
* This php pagination code was developed by Underdog copyright 2013
* http://webdevelop.comli.com
* Licensed under the GNU Public License: http://www.gnu.org/licenses/gpl.html
*/
global $context, $txt, $scripturl;

$name = 'custom_SpForm' . $id;
$pageCount = 1;
$display = array('page' => false, 'pages' => '0');
$page = !empty($context['current_page' . $id]) ? (int)$context['current_page' . $id] : 0;
$display['pages'] = !empty($pages) ? (int)$pages : 1;

if ($display['pages'] > 1)
{
$display['page'] =  '
<script type="text/javascript"><!-- // --><![CDATA[
function changeColor(s, formId)
{
for (var i=1; i<=3; i++)
                document.getElementById("link"+i+formId).style.color = i==s ? "red" : "blue";
}
function changeColorBack(s, formId)
{
for (var i=1; i<=3; i++)
document.getElementById("link"+i+formId).style.color = i==s ? "blue" : "blue";
}
// ]]></script>
<form name="' . $name .'" action="'.$link.'" method="post" id="' . $name .'">
<span style="text-align:center;position:relative;width:99%;display:inline-block;">
' . $lang . '<br />';

while ($pageCount < (int)$display['pages']+1)
{
$current_page = (int)$page+1;
$total = (int)$display['pages'];
       
if ($pageCount == 1 || $pageCount == $total || $pageCount == $current_page || $pageCount == $current_page+1 ||
    $pageCount == $current_page+2 || $pageCount == $current_page-1 || $pageCount == $current_page-2)
{
                if ((int)$pageCount == (int)$page+1)
$display['page'] .= '
[<input class="' . $style . '" type="button" onclick="this.href=\'javascript: void(0)\';" onmouseout="changeColorBack('. $pageCount . ', ' . $id . ')" onmouseover="changeColor(' . $pageCount . ', ' . $id . ')" id="link' . $pageCount . $id . '" style="border:0;padding:0;margin:0;color:blue;text-decoration:none;" name="current_page' . $id . '" value="' . $pageCount . '" />] ';
        else
$display['page'] .= '
<input class="' . $style . '" type="submit" onmouseout="changeColorBack(' . $pageCount . ', ' . $id . ')" onmouseover="changeColor(' . $pageCount . ', ' . $id . ')" id="link' . $pageCount . $id . '" style="border:0;padding:0;margin:0;color:blue;text-decoration:none;" name="current_page' . $id . '" value="' . $pageCount . '"  /> ';
}
elseif ($pageCount < $current_page-2 && $pageCount > $current_page-6)
$display['page'] .= '
<input class="' . $style . '" type="submit" onchange="document.getElementById(\'link' . $pageCount . $id . '\').value='.$pagecount.'" onmouseout="changeColorBack(' . $pageCount . ', ' . $id . ')" onmouseover="changeColor(' . $pageCount . ', ' . $id . ')" id="link' . $pageCount . $id . '" style="border:0;padding:0;margin:0;color:blue;text-decoration:none;" name="current_page' . $id . '" value="." onclick="sp_submitPage();" /> ';
elseif ($pageCount > $current_page+2 && $pageCount < $current_page+6)
$display['page'] .= '
<input class="' . $style . '" type="submit" onchange="document.getElementById(\'link' . $pageCount . $id . '\').value='.$pagecount.'" onmouseout="changeColorBack(' . $pageCount . ', ' . $id . ')" onmouseover="changeColor(' . $pageCount . ', ' . $id . ')" id="link' . $pageCount . $id . '" style="border:0;padding:0;margin:0;color:blue;text-decoration:none;" name="current_page' . $id . '" value="." onclick="sp_submitPage();" /> ';

$pageCount++;
}

$display['page'] .= '
</span>   
</form>';
}

return $display;
}

/* Current url */
function currentCustomPage($pageURL = 'http://')
{
if (!empty($_SERVER["HTTPS"]))
$pageURL = "https://";   
   
if ($_SERVER["SERVER_PORT"] != "80")
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
else
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];

return $pageURL;
}

function customRecent($parameters)
{
global $txt, $scripturl, $settings, $context, $color_profile;

$boards = !empty($parameters['boards']) ? explode('|', $parameters['boards']) : null;
$limit = !empty($parameters['limit']) ? (int)$parameters['limit'] : 15;
$type = 'ssi_recent' . (empty($parameters['type']) ? 'Posts' : 'Topics');
$display = empty($parameters['display']) ? 'compact' : 'full';
$style = !empty($parameters['bodyStyle']) ? $parameters['bodyStyle'] : 'windowbg';
$id = !empty($parameters['formId']) ? (int)$parameters['formId'] : 1;
$perPage = !empty($parameters['perPage']) ? (int)$parameters['perPage'] : 10;

// $recent_items = $type($limit, null, $boards, 'array');
       
        $items = custom_pagination($type($limit, null, $boards, 'array'), $perPage, $id);       
       
        $context['custom_display' . $id] = array('page' => false, 'pages' => '0');
$context['custom_display' . $id] = custom_pages($txt['pages'], false, currentCustomPage(), $context['current_pages' . $id], false, false, $id, $style);
       
if (empty($items))
{
echo '
', $txt['error_sp_no_posts_found'];
return;
}
else
$items[count($items) - 1]['is_last'] = true;

$colorids = array();
foreach ($items as $item)
$colorids[] = $item['poster']['id'];

if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($items as $k => $p)
{
if (!empty($color_profile[$p['poster']['id']]['link']))
$items[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
}
}

if ($display == 'compact')
{
foreach ($items as $key => $item)
echo '
<a href="', $item['href'], '">', $item['subject'], '</a> <span class="smalltext">', $txt['by'], ' ', $item['poster']['link'], $item['new'] ? '' : ' <a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '<br />[', $item['time'], ']</span><br />', empty($item['is_last']) ? '<hr />' : '';
}
elseif ($display == 'full')
{
echo '
<table class="sp_fullwidth">';

foreach ($items as $item)
echo '
<tr>
<td class="sp_recent_icon sp_center">
', sp_embed_image(empty($parameters['type']) ? 'post' : 'topic'), '
</td>
<td class="sp_recent_subject">
<a href="', $item['href'], '">', $item['subject'], '</a>
', $item['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '<br />[', $item['board']['link'], ']
</td>
<td class="sp_recent_info sp_right">
', $item['poster']['link'], '<br />', $item['time'], '
</td>
</tr>';

echo '
</table>';
}
       
        echo $context['custom_display' . $id]['page'];   
}

First thanks for the above code,  i will like to add one or two things to it and i need your help.

I. i want to add something like a border on each news seperting each from another,

2. i will like to add this bellow the each news.



3. to give boder to the images that the board news will display.

Currently i am using a this code i got here at http://simpleportal.net/index.php?topic=10766.msg68082#msg68082 on my forum, but required editing of the portalblocks.php, but i will like to use this one since i wont loss any thing during upgrade. My issue now is how to do the above, i tried editing an i got some Syntax error.
« Last Edit: February 15, 2015, 07:31:01 AM by sub5 »