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

Thanks for having an interest with our portal. If you have any requests for features, have a look at the Feature Requests board.

Author Topic: Something that can list all topics in a board  (Read 35376 times)

0 Members and 1 Guest are viewing this topic.

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #20 on: May 10, 2010, 10:33:27 AM »
Yes.  You must call the function in order to execute it.
But I am confused, and probably I am confusing you.
Please post the entire code you are including in the block.
 
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 johncccccc

  • Jr. Member
  • **
  • Posts: 92
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #21 on: May 10, 2010, 10:38:11 AM »
Yes.  You must call the function in order to execute it.
But I am confused, and probably I am confusing you.
Please post the entire code you are including in the block.

The above code was it lol..

Code: [Select]
<?php
$boxy_params 
= array(
'board' => 'boards',
'limit' => 'int',
'start' => 'int',
'length' => 'int',
'avatar' => 'check',
'per_page' => 'int',
'per_row' => 'int',
);

sp_boxynews($boxy_params0);
   echo 
'
               <table class="sp_boxynews_container">
      '
;
      
$num_in_row 0;
      foreach (
$return as $news)
      {
         
$num_in_row++;
         if (
$num_in_row == $per_row)
         {
            echo 
'
               </tr>
            '
;
            
$num_in_row 1;
         }

         if (
$num_in_row == )
         {
            echo 
'
               <tr>
            '
;
         }}
   
   echo 
'
      <td>
'
;

?>

minus the <?php and ?>

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #22 on: May 10, 2010, 11:24:28 AM »
I am guessing this is your introduction to programming. It may be a tough way to start!
If you think you will like to do programming in the future, I recommend you try a "for-beginners" tutorial to help you get comfortable with basic programming concepts *
 
I'm going to repeat myself, with slightly different words. Please let me know if you think you are ready to try this kind of thing or not.
 
1) Copy the entire function definition (beginning with function boardnews and ending with the } just before the beginning of the next function into a text editor.
 
1a) Rename that function to be function boxynews, but do not change anything within that function definition just yet.
 
1c) Do not add any <?php or ?> tags
 
2) After the end of that function definition, add the lines
Code: [Select]
$boxy_params = array(
      'board' => 1,
      'limit' => '',
      'start' => '',
      'length' => '',
      'avatar' => '',
      'per_page' => '12',
      'per_row' => '3',
   );

sp_boxynews($boxy_params, 0);

3) Copy the whole thing -- the function definition, followed by the lines setting up the array $boxy_params, and finally calling the function sp_boxynews -- into a custom php php page.  Test and make sure it runs OK.  It should create something JUST LIKE BOARDNEWS.  YAY! GOOD START
 
4) Now, you will start modifying the function definition. In your text editor, make the following one-line change.  Then copy the WHOLE CONTENTS OF THE TEXT EDITOR (including the function definition the code afterwards to run the function) into your custom php page and test it.
find
Code: (FIND THIS PART OF THE CODE) [Select]
  $block_parameters = array(
'board' => 'boards',
'limit' => 'int',
'start' => 'int',
'length' => 'int',
'avatar' => 'check',
'per_page' => 'int',
); 
and change it to look like this:
Code: (REPLACE) [Select]
  $block_parameters = array(
'board' => 'boards',
'limit' => 'int',
'start' => 'int',
'length' => 'int',
'avatar' => 'check',
'per_page' => 'int',
'per_row' => 'int',
);

---------------------------------------------
 
* http://devzone.zend.com/article/627 or http://php.net/manual/en/tutorial.php
or even a Python tutorial
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 johncccccc

  • Jr. Member
  • **
  • Posts: 92
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #23 on: May 10, 2010, 11:51:05 AM »
Line 1256 of PortalBlocks.php is:

function sp_boardNews($parameters, $id, $return_parameters = false)

The Entire definition is?
Code: [Select]
function sp_boardNews($parameters, $id, $return_parameters = false)
{
global $scripturl, $txt, $settings, $modSettings, $context, $smcFunc, $color_profile;

$block_parameters = array(
'board' => 'boards',
'limit' => 'int',
'start' => 'int',
'length' => 'int',
'avatar' => 'check',
'per_page' => 'int',
);

if ($return_parameters)
return $block_parameters;

$board = !empty($parameters['board']) ? explode('|', $parameters['board']) : null;
$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
$start = !empty($parameters['start']) ? (int) $parameters['start'] : 0;
$length = isset($parameters['length']) ? (int) $parameters['length'] : 250;
$avatars = !empty($parameters['avatar']);
$per_page = !empty($parameters['per_page']) ? (int) $parameters['per_page'] : 0;

$limit = max(0, $limit);
$start = max(0, $start);

loadLanguage('Stats');

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$request = $smcFunc['db_query']('', '
SELECT t.id_first_msg
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE ' . (empty($board) ? '{query_see_board}
AND t.id_first_msg >= {int:min_msg_id}' : 't.id_board IN ({array_int:current_board})') . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}' : '') . '
AND (t.locked != {int:locked} OR m.icon != {string:icon})
ORDER BY t.id_first_msg DESC
LIMIT {int:limit}',
array(
'current_board' => $board,
'min_msg_id' => $modSettings['maxMsgID'] - 45 * min($limit, 5),
'is_approved' => 1,
'locked' => 1,
'icon' => 'moved',
'limit' => $limit,
)
);
$posts = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$posts[] = $row['id_first_msg'];
$smcFunc['db_free_result']($request);

if (empty($posts))
{
echo '
', $txt['error_sp_no_posts_found'];
return;
}
elseif (!empty($per_page))
{
$limit = count($posts);
$start = !empty($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;

$clean_url = preg_replace('~(;|\?)?sa=news;start=\d+~', '', $_SERVER['REQUEST_URL']);
$current_url = $clean_url . (strpos($clean_url, '?') !== false ? ';' : '?');

$page_index = constructPageIndex($current_url . '?sa=news', $start, $limit, $per_page);
}

$request = $smcFunc['db_query']('', '
SELECT
m.icon, m.subject, m.body, IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time,
t.num_replies, t.id_topic, m.id_member, m.smileys_enabled, m.id_msg, t.locked, mem.avatar,
a.id_attach, a.attachment_type, a.filename, t.num_views
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE t.id_first_msg IN ({array_int:post_list})
ORDER BY t.id_first_msg DESC
LIMIT ' . (!empty($per_page) ? '{int:start}, ' : '') . '{int:limit}',
array(
'post_list' => $posts,
'start' => $start,
'limit' => !empty($per_page) ? $per_page : $limit,
)
);
$return = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (($cutoff = $smcFunc['strpos']($row['body'], '')) !== false)
$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
elseif (!empty($length) && $smcFunc['strlen']($row['body']) > $length)
$row['body'] = $smcFunc['substr']($row['body'], 0, $length);

$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']) . '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0" title="' . $row['subject'] . '">...</a>';

if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = '';
$avatar_height = '';
}

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

censorText($row['subject']);
censorText($row['body']);


if ($modSettings['sp_resize_images'])
$row['body'] = preg_replace('~class="bbc_img"~i', 'class="bbc_img sp_article"', $row['body']);

if (!empty($row['id_member']))
$colorids[$row['id_member']] = $row['id_member'];

$return[] = array(
'id' => $row['id_topic'],
'message_id' => $row['id_msg'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
'subject' => $row['subject'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'timeyear' => timeformat($row['poster_time'], '%d %b %y'),
'timeday' => timeformat($row['poster_time'], '%H:%M:%S'),
'views' => $row['num_views'],
'body' => $row['body'],
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $txt['sp-read_more'] . '</a>',
'replies' => $row['num_replies'],
'comment_href' => !empty($row['locked']) ? '' : $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'],
'comment_link' => !empty($row['locked']) ? '' : '| <a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>',
'new_comment' => !empty($row['locked']) ? '' : '| <a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>',
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : '',
'link' => !empty($row['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>' : $row['poster_name']
),
'locked' => !empty($row['locked']),
'is_last' => false,
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
),
);
}
$smcFunc['db_free_result']($request);

if (empty($return))
{
echo '
', $txt['error_sp_no_posts_found'];
return;
}

$return[count($return) - 1]['is_last'] = true;

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

if ($context['SPortal']['core_compat'])
{
foreach ($return as $news)
{
echo '
<div class="tborder">
<table class="sp_block">
<tr class="catbg">
<td class="sp_middle">', $news['icon'], '</td>
<td class="sp_middle sp_regular_padding sp_fullwidth"><a href="', $news['href'], '" >', $news['subject'], '</a> | ', $news['timeyear'], '</td>
</tr>
<tr class="windowbg">
<td class="sp_regular_padding" colspan="2">';

if ($avatars && $news['avatar']['name'] !== null && !empty($news['avatar']['href']))
echo '
<img src="', $news['avatar']['href'], '" alt="', $news['poster']['name'], '" width="30" style="float: right;" />
<div class="middletext">', $news['timeday'], ' ', $txt['by'], ' ', $news['poster']['link'], '<br />', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';
else
echo '
<div class="middletext">', $news['timeday'], ' ', $txt['by'], ' ', $news['poster']['link'], ' | ', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';

echo '
<div class="post"><hr />', $news['body'], '<br /><br /></div>
</td>
</tr>
<tr>
<td class="windowbg2" colspan="2">
<div class="sp_right sp_regular_padding">', $news['link'], ' ',  $news['new_comment'], '</div>
</td>
</tr>
</table>
</div>
<br />';
}
}
else
{
foreach ($return as $news)
{
echo '
<h3 class="catbg"><span class="left"></span>
<span class="sp_float_left sp_article_icon">', $news['icon'], '</span><a href="', $news['href'], '" >', $news['subject'], '</a> | ', $news['timeyear'], '
</h3>
<div class="windowbg">
<span class="topslice"><span></span></span>
<div class="sp_content_padding">';

if ($avatars && $news['avatar']['name'] !== null && !empty($news['avatar']['href']))
echo '
<img src="', $news['avatar']['href'], '" alt="', $news['poster']['name'], '" width="30" class="sp_float_right" />
<div class="middletext">', $news['timeday'], ' ', $txt['by'], ' ', $news['poster']['link'], '<br />', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';
else
echo '
<div class="middletext">', $news['timeday'], ' ', $txt['by'], ' ', $news['poster']['link'], ' | ', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';

echo '
<div class="post"><hr />', $news['body'], '</div>
<div class="sp_right">', $news['link'], ' ',  $news['new_comment'], '</div>
</div>
<span class="botslice"><span></span></span>
</div>
<br />';
}
}

if (!empty($per_page))
echo '
<div class="sp_page_index">', $txt['sp-articlesPages'], ': ', $page_index, '</div>';

echo '
<br />';
}

function sp_quickSearch($parameters, $id, $return_parameters = false)
{
global $scripturl, $txt, $context;

$block_parameters = array();

if ($return_parameters)
return $block_parameters;

echo '
<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<div class="sp_center">
<input type="text" name="search" value="" class="sp_search" /><br />
<input type="submit" name="submit" value="', $txt['search'], '" />
<input type="hidden" name="advanced" value="0" />
</div>
</form>';
}

Ending on line 1528, or is the definition just part of that?

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #24 on: May 10, 2010, 12:42:23 PM »
Yes. Well, actually, you grabbed two functions, sp_boardnews and sp_quicksearch. But I think you get the idea.

The function definition begins with function name-of-function(....){ and includes everything until the matching closing curly-bracket }
 
You are starting to get the hang of this.
I now have a better idea of your prev. programming experience.
Don't worry.
 
Make and test the first one-line change I gave you.
-------------------------------------------------------------------
 
I'll be able to offer you more help tomorrow.

 
 
 
 
« Last Edit: May 11, 2010, 01:34:53 PM 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 AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #25 on: May 11, 2010, 02:08:27 PM »
John,
 
Here's what I've been talking about.
Right at the top, I've picked 'board' => 2, but  you need to choose the board you want.
Similarly for the other boxy_params.
 
Would you be able to pull out the stuff you don't want in your block?
 
Code: [Select]
$boxy_params = array(
'board' => 2,
'limit' => 1000,
'length' => 20,
'per_page' => 9,
'per_row' => 3,
);
function sp_boxyNews($parameters, $id, $return_parameters = false)
{
   global $scripturl, $txt, $settings, $modSettings, $context, $smcFunc, $color_profile;
   $block_parameters = array(
      'board' => 'boards',
      'limit' => 'int',
      'start' => 'int',
      'length' => 'int',
      'avatar' => 'check',
      'per_page' => 'int',
      'per_row' => 'int',
   );
   if ($return_parameters)
      return $block_parameters;
   $board = !empty($parameters['board']) ? explode('|', $parameters['board']) : null;
   $limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
   $start = !empty($parameters['start']) ? (int) $parameters['start'] : 0;
   $length = isset($parameters['length']) ? (int) $parameters['length'] : 250;
   $avatars = !empty($parameters['avatar']);
   $per_page = !empty($parameters['per_page']) ? (int) $parameters['per_page'] : 0;
   $per_row = !empty($parameters['per_row']) ? (int) $parameters['per_row'] : 1;
   $limit = max(0, $limit);
   $start = max(0, $start);
   loadLanguage('Stats');
   $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
   $icon_sources = array();
   foreach ($stable_icons as $icon)
      $icon_sources[$icon] = 'images_url';
   $request = $smcFunc['db_query']('', '
      SELECT t.id_first_msg
      FROM {db_prefix}topics AS t
         INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
         INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
      WHERE ' . (empty($board) ? '{query_see_board}
         AND t.id_first_msg >= {int:min_msg_id}' : 't.id_board IN ({array_int:current_board})') . ($modSettings['postmod_active'] ? '
         AND t.approved = {int:is_approved}' : '') . '
         AND (t.locked != {int:locked} OR m.icon != {string:icon})
      ORDER BY t.id_first_msg DESC
      LIMIT {int:limit}',
      array(
         'current_board' => $board,
         'min_msg_id' => $modSettings['maxMsgID'] - 45 * min($limit, 5),
         'is_approved' => 1,
         'locked' => 1,
         'icon' => 'moved',
         'limit' => $limit,
      )
   );
   $posts = array();
   while ($row = $smcFunc['db_fetch_assoc']($request))
      $posts[] = $row['id_first_msg'];
   $smcFunc['db_free_result']($request);
   if (empty($posts))
   {
      echo '
            ', $txt['error_sp_no_posts_found'];
      return;
   }
   elseif (!empty($per_page))
   {
      $limit = count($posts);
      $start = !empty($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
      $clean_url = preg_replace('~(;|\?)?sa=news;start=\d+~', '', $_SERVER['REQUEST_URL']);
      $current_url = $clean_url . (strpos($clean_url, '?') !== false ? ';' : '?');
      $page_index = constructPageIndex($current_url . '?sa=news', $start, $limit, $per_page);
   }
   $request = $smcFunc['db_query']('', '
      SELECT
         m.icon, m.subject, m.body, IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time,
         t.num_replies, t.id_topic, m.id_member, m.smileys_enabled, m.id_msg, t.locked, mem.avatar,
         a.id_attach, a.attachment_type, a.filename, t.num_views
      FROM {db_prefix}topics AS t
         INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
         LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
         LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
      WHERE t.id_first_msg IN ({array_int:post_list})
      ORDER BY t.id_first_msg DESC
      LIMIT ' . (!empty($per_page) ? '{int:start}, ' : '') . '{int:limit}',
      array(
         'post_list' => $posts,
         'start' => $start,
         'limit' => !empty($per_page) ? $per_page : $limit,
      )
   );
   $return = array();
   $colorids = array();
   while ($row = $smcFunc['db_fetch_assoc']($request))
   {
      if (($cutoff = $smcFunc['strpos']($row['body'], '')) !== false)
         $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
      elseif (!empty($length) && $smcFunc['strlen']($row['body']) > $length)
         $row['body'] = $smcFunc['substr']($row['body'], 0, $length);
      $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']) . '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0" title="' . $row['subject'] . '">...</a>';
      if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
      {
         $avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
         $avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
      }
      else
      {
         $avatar_width = '';
         $avatar_height = '';
      }
      if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
         $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';
      censorText($row['subject']);
      censorText($row['body']);

      if ($modSettings['sp_resize_images'])
         $row['body'] = preg_replace('~class="bbc_img"~i', 'class="bbc_img sp_article"', $row['body']);
      if (!empty($row['id_member']))
         $colorids[$row['id_member']] = $row['id_member'];
      $return[] = array(
         'id' => $row['id_topic'],
         'message_id' => $row['id_msg'],
         'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
         'subject' => $row['subject'],
         'time' => timeformat($row['poster_time']),
         'timestamp' => forum_time(true, $row['poster_time']),
         'timeyear' => timeformat($row['poster_time'], '%d %b %y'),
         'timeday' => timeformat($row['poster_time'], '%H:%M:%S'),
         'views' => $row['num_views'],
         'body' => $row['body'],
         'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
         'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $txt['sp-read_more'] . '</a>',
         'replies' => $row['num_replies'],
         'comment_href' => !empty($row['locked']) ? '' : $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'],
         'comment_link' => !empty($row['locked']) ? '' : '| <a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>',
         'new_comment' => !empty($row['locked']) ? '' : '| <a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>',
         'poster' => array(
            'id' => $row['id_member'],
            'name' => $row['poster_name'],
            'href' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : '',
            'link' => !empty($row['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>' : $row['poster_name']
         ),
         'locked' => !empty($row['locked']),
         'is_last' => false,
         'avatar' => array(
            'name' => $row['avatar'],
            'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
            'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
            'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
         ),
      );
   }
   $smcFunc['db_free_result']($request);
   if (empty($return))
   {
      echo '
            ', $txt['error_sp_no_posts_found'];
      return;
   }
   $return[count($return) - 1]['is_last'] = true;
   if (!empty($colorids) && sp_loadColors($colorids) !== false)
   {
      foreach ($return as $k => $p)
      {
         if (!empty($color_profile[$p['poster']['id']]['link']))
            $return[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
      }
   }
   if ($context['SPortal']['core_compat'])
   {
   echo '
  <table class="sp_boxynews_container">
      ';
      $num_in_row = 0;
      foreach ($return as $news)
      {
         $num_in_row++;
         if ($num_in_row > $per_row)
         {
            echo '
        </tr>
            ';
            $num_in_row = 1;
         }
         if ($num_in_row == 1 )
         {
            echo '
   <tr>
            ';
         }
   
     echo '
         <td>
';
         echo '
               <div class="tborder">
                  <table class="sp_block">
                     <tr class="catbg">
                        <td class="sp_middle">', $news['icon'], '</td>
                        <td class="sp_middle sp_regular_padding sp_fullwidth"><a href="', $news['href'], '" >', $news['subject'], '</a> | ', $news['timeyear'], '</td>
                     </tr>
                     <tr class="windowbg">
                        <td class="sp_regular_padding" colspan="2">';
         if ($avatars && $news['avatar']['name'] !== null && !empty($news['avatar']['href']))
            echo '
                           <img src="', $news['avatar']['href'], '" alt="', $news['poster']['name'], '" width="30" style="float: right;" />
                           <div class="middletext">', $news['timeday'], ' ', $txt['by'], ' ', $news['poster']['link'], '<br />', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';
         else
            echo '
                           <div class="middletext">', $news['timeday'], ' ', $txt['by'], ' ', $news['poster']['link'], ' | ', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';
         echo '
                           <div class="post"><hr />', $news['body'], '<br /><br /></div>
                        </td>
                     </tr>
                     <tr>
                        <td class="windowbg2" colspan="2">
                           <div class="sp_right sp_regular_padding">', $news['link'], ' ',  $news['new_comment'], '</div>
                        </td>
                     </tr>
                  </table>
               </div>
               </td>';
      }
      echo '</table>';   
   }
   else
   {
   echo '
  <table class="sp_boxynews_container">
      ';
      $num_in_row = 0;     
      foreach ($return as $news)
      {
         $num_in_row++;
         echo '<!-- num in row ', $num_in_row, " -->\n";
         if ($num_in_row > $per_row)
         {
            echo '
            <!-- closing row -->
        </tr>
            ';
            $num_in_row = 1;
         }
         if ($num_in_row == 1 )
         {
            echo '
            <!-- starting new row -->
   <tr>
            ';
         }
  echo '<!-- <b> item </b>', $num_in_row, "<br /> -->\n";   
   
     echo '
         <td>
'; 
         echo '
               <h3 class="catbg"><span class="left"></span>
                  <span class="sp_float_left sp_article_icon">', $news['icon'], '</span><a href="', $news['href'], '" >', $news['subject'], '</a> | ', $news['timeyear'], '
               </h3>
               <div class="windowbg">
                  <span class="topslice"><span></span></span>
                  <div class="sp_content_padding">';
         if ($avatars && $news['avatar']['name'] !== null && !empty($news['avatar']['href']))
            echo '
                     <img src="', $news['avatar']['href'], '" alt="', $news['poster']['name'], '" width="30" class="sp_float_right" />
                     <div class="middletext">', $news['timeday'], ' ', $txt['by'], ' ', $news['poster']['link'], '<br />', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';
         else
            echo '
                     <div class="middletext">', $news['timeday'], ' ', $txt['by'], ' ', $news['poster']['link'], ' | ', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], '</div>';
         echo '
                     <div class="post"><hr />', $news['body'], '</div>
                     <div class="sp_right">', $news['link'], ' ',  $news['new_comment'], '</div>
                  </div>
                  <span class="botslice"><span></span></span>
               </div>
               </td>';
      }
      echo '</table>';   
   }
   if (!empty($per_page))
      echo '
               <div class="sp_page_index">', $txt['sp-articlesPages'], ': ', $page_index, '</div>';
   echo '
            <br />';
}
 
sp_boxynews($boxy_params, 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 johncccccc

  • Jr. Member
  • **
  • Posts: 92
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #26 on: May 23, 2010, 11:25:00 PM »
OMG that looks great, looking at the code you have put, I would have taken a lifetime to get that right, it seems that the cutoff point is not activated, where in the code (I have not looked yet) does it control the character cutoff? (got it never mind)
However, the activation of the cutoff point with that would be great if you could guide me on that, looking at the code, I think its not really possible for me, I think its too late to start trying to get this now, its almost perfect already :)

Thank you very much! :)

EDIT:

This issue also, otherwise its perfect


1. Enable cutoff point
2. Fix the alignment

Were done :D
« Last Edit: May 23, 2010, 11:38:52 PM by johncccccc »

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #27 on: May 24, 2010, 10:56:40 AM »
I'm glad this is helping you.
 
I made a pretty simple change to the boardnews block. Because it isn't the officially-registered boardnews block, you can't use the block editor, but the options are all still there.
 
1) Your cutoff options are:
   a) use the length element of the $boxy_params array
   a) use the [cutoff] tag in the post -- that overrides length
 
2) Aligning things in table elements is something you can do in CSS.  Your boxynews function has everything in <table class="sp_boxynews_container">. portal.css would be a logical place to include your favorite styling options.  I have always found w3schools.com a good place to review and test out CSS style options.
Code: [Select]
table.sp_boxynews_container td
{
        vertical-align: top;
}

3) If just aligning the tops of the boxes doesn't do it for you, you will need to fiddle with the php code a little bit to get rid of the <div> that the post body currently gets stuffed into.
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 johncccccc

  • Jr. Member
  • **
  • Posts: 92
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #28 on: May 25, 2010, 09:45:04 AM »
I'm glad this is helping you.
 
I made a pretty simple change to the boardnews block. Because it isn't the officially-registered boardnews block, you can't use the block editor, but the options are all still there.
 
1) Your cutoff options are:
   a) use the length element of the $boxy_params array
   a) use the [cutoff] tag in the post -- that overrides length
 
2) Aligning things in table elements is something you can do in CSS.  Your boxynews function has everything in <table class="sp_boxynews_container">. portal.css would be a logical place to include your favorite styling options.  I have always found w3schools.com a good place to review and test out CSS style options.
Code: [Select]
table.sp_boxynews_container td
{
        vertical-align: top;
}

3) If just aligning the tops of the boxes doesn't do it for you, you will need to fiddle with the php code a little bit to get rid of the <div> that the post body currently gets stuffed into.

Thanks, its helping a lot, my game reviews page is getting underway now :)

The cutoff tag has no effect, haven't a clue why, I will tinker with the alignment issue a little bit before asking for more help, thanks a lot, I will report any progress and further issues :)

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #29 on: May 25, 2010, 10:25:54 AM »
Seems cutoff is not working because I broke it  :-[ . Not sure how!
Code: (find) [Select]
if (($cutoff = $smcFunc['strpos']($row['body'], '')) !== false)
Code: (replace) [Select]
if (($cutoff = $smcFunc['strpos']($row['body'], '['. 'cutoff]')) !== false)

-----------------
edit -- by posting it here, that's how.  You don't really want '['. 'cutoff]', but SimplePortal will remove the cutoff tag even if you try to protect it with nobbc or code tags!
 
 
« Last Edit: August 17, 2010, 01:02:09 PM 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 johncccccc

  • Jr. Member
  • **
  • Posts: 92
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #30 on: May 25, 2010, 12:37:25 PM »
Seems cutoff is not working because I broke it  :-[ . Not sure how!
Code: (find) [Select]
if (($cutoff = $smcFunc['strpos']($row['body'], '')) !== false)
Code: (replace) [Select]
if (($cutoff = $smcFunc['strpos']($row['body'], '')) !== false)
I was about to post about the failing of seeing the cutoff change, but now im quoting it I can, needs the nobbc tag lol
[nobcc]if (($cutoff = $smcFunc['strpos']($row['body'], '')) !== false)[/nobbc]

EDIT:
Now just for the alignment

Thanks :)
« Last Edit: May 25, 2010, 12:42:32 PM by johncccccc »

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #31 on: May 25, 2010, 02:24:20 PM »
That is so unfair that tags are stripped from inside a [code] block!
 
I think you will soon have the tops of the boxes aligned, but not the bottoms.
No amount of CSS will fix that.
 
If it is a problem, you will have to switch from <div> to tables. Because Tables automatically make all cells in the same row to be the same height.
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 johncccccc

  • Jr. Member
  • **
  • Posts: 92
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #32 on: May 25, 2010, 02:45:40 PM »
That is so unfair that tags are stripped from inside a [code] block!
 
I think you will soon have the tops of the boxes aligned, but not the bottoms.
No amount of CSS will fix that.
 
If it is a problem, you will have to switch from <div> to tables. Because Tables automatically make all cells in the same row to be the same height.

Yes, I think a html table would suffice, would it be much work to change that?
What would I have to change?

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #33 on: May 25, 2010, 02:51:52 PM »
Instead of putting in one row of a table per row of boxes, now the code needs to be rewritten to plan ahead a bit, because it has to put in two table rows per row of boxes.  The first row will contain the title (the part in <h3 class="catbg">. The second row will contain the stuff that is now in <div class="windowbg">.  So this takes a little thought.
 
Are you up for that, or will you wait until someone else has time to look into it?
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 johncccccc

  • Jr. Member
  • **
  • Posts: 92
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #34 on: May 25, 2010, 03:59:58 PM »
Instead of putting in one row of a table per row of boxes, now the code needs to be rewritten to plan ahead a bit, because it has to put in two table rows per row of boxes.  The first row will contain the title (the part in <h3 class="catbg">. The second row will contain the stuff that is now in <div class="windowbg">.  So this takes a little thought.
 
Are you up for that, or will you wait until someone else has time to look into it?

I think I will work on fixing the current, I'm not very good ,I have a very limited basic understanding of the code here

Thanks.

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #35 on: May 26, 2010, 02:06:24 PM »
In your Sources directory, the attached file.
In your custom php block:
Code: [Select]
$boxy_params = array(
'board' => 4,
'limit' => 1000,
'length' => 200,
'per_page' => 8,
'per_row' => 3,
);
global $sourcedir;
require_once ($sourcedir . '/boxynews.php');
sp_boxynews($boxy_params, 0);

-----
Edit: fixed pagination bug in attachment
 
 
 
« Last Edit: June 07, 2010, 12:51:47 PM 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 johncccccc

  • Jr. Member
  • **
  • Posts: 92
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #36 on: June 04, 2010, 01:38:48 PM »
WOW..

I have no Idea whats so different in the code there, but it looks great, everything is aligned perfectly now

Just one issue, preventing perfection, I gather its a CSS problem, something in the older code did not create this issue, image below



The blue is "highlighted", I highlighted it to show the text which is hidden due to the bg being black as well as the text, seems like the CSS image is not been shown
This should be the last of changes to finally get this working right :)

Thanks a lot for your help
« Last Edit: June 04, 2010, 01:42:03 PM by johncccccc »

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #37 on: June 04, 2010, 03:05:03 PM »
Yes -- the CSS you want for that cell will depend on your theme.
Fortunately, the class "sp_boxynews_container" gives you something to work with:
You should be able to add this to portal.css
Code: [Select]
table.sp_boxynews_container div.sp_right
{
    background-color: gray;
    text-color: black;
}
You can fiddle
 
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 johncccccc

  • Jr. Member
  • **
  • Posts: 92
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #38 on: June 05, 2010, 12:10:50 PM »
Darn...
Tried that its not fixing anything, something changed, in the old code it never did that, whats different in the new code, that could possibly relate to the appearance in the PHP code.


EDIT:
Got it :D

the CSS change was:
Code: [Select]
table.sp_boxynews_container .sp_regular_padding
{
    background-color: gray;
    text-color: black;
}

Thanks for all your help :)

One last thing, now to center the contents of the blocks (not the actual blocks) I already did that :P

EDIT 3:

Never mind done that too

Code: [Select]
table.sp_boxynews_container .sp_regular_padding
{
    background-color: gray;
    text-color: black;
    text-align: center;
}

I think perfection has possibly been hit! :)

Thanks so much :)
« Last Edit: June 06, 2010, 10:19:08 PM by johncccccc »

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Something that can list all topics in a board
« Reply #39 on: June 07, 2010, 10:50:23 AM »
I'm very glad to help you figure some of this out.
With a little reading, you will be an expert in no time  :)
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?