SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: johncccccc on April 18, 2010, 11:14:16 PM

Title: Something that can list all topics in a board
Post by: johncccccc on April 18, 2010, 11:14:16 PM
I would like a block that will list all topics that are in a given board with links to the topic of course.

The idea is to make the portal and forum more into each other by adding some boards topics linked on a simple portal page or block.

Thanks in advanced.
Title: Re: Something that can list all topics in a board
Post by: Nathaniel on April 19, 2010, 02:52:13 AM
Well, the BoardNews and Recent block types already allow you to do this, just only set a single board to be shown by them.
Title: Re: Something that can list all topics in a board
Post by: johncccccc on April 19, 2010, 09:26:24 AM
Well, the BoardNews and Recent block types already allow you to do this, just only set a single board to be shown by them.

Arhh, ok.

The recent block type seems to be the closest, but it only displays recently posted topics.

Let me be more detailed on what I'm doing here, I will be using this for a game review area in the forum, I already have setup a form (custom forms mod) to get uniform posts when adding reviews, I would like to list the reviews on a page away from the forum, and when clicked then the viewer will be directed to the post. A little example of what I mean is below.

A simple portal custom page with custom PHP block inside would:



Sakura Wars: So Long My Love Review for PS2  - The topic subject (with link to topic) (possibly "by AUTHOR" here too)
(http://i2.photobucket.com/albums/y22/BlackDragonIncarnate/29111309-sw2_thumb.jpg)possibly a  thumbnail for the review
Every review starts with an image of the box, as controlled by the custom forms mod.

Something that lists all topics like that would be great, thanks in advanced
Title: Re: Something that can list all topics in a board
Post by: johncccccc on April 20, 2010, 01:19:54 PM
I don't mean to be a bother..

My game review section of the form just needs this one block, in the above post, Ive used the custom forms mod to make a post output for the review, so there always the same layout, also the board is "reply only", so the only way to add a review is via the form mod.
(http://i40.tinypic.com/14scr4g.jpg)

That's the form, this is the output:

(http://i42.tinypic.com/9ade9l.jpg)

I also have a reviews tab I added to my form, then linked it to a simple portal page, which is where I want the above block, to make a true section, not just another board.

(http://i40.tinypic.com/2i1hz4p.png)

At this time The staff are manually adding these review links there, With this block, I would just add the block and it will do this automatically.

Thanks again..
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on April 20, 2010, 08:00:41 PM
Are you not getting enough posts in the recent topics block?
 
Would an articles block do what you want?
 
 
Title: Re: Something that can list all topics in a board
Post by: johncccccc on April 20, 2010, 08:29:09 PM
Are you not getting enough posts in the recent topics block?
 
Would an articles block do what you want?

It would be similar to an articles block, but it would display as I have posted above, instead of listing some characters, it would just get the 1st image, and resize it, to thumbnail size then display it in the area.

Then of course the text would be there too with a link to the actual review
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on April 20, 2010, 08:51:27 PM
Have you tried the [cutoff] tag? You could put it right after the image.

 
--------------------
edit: put nobbc tag around [cutoff]
Title: Re: Something that can list all topics in a board
Post by: johncccccc on April 21, 2010, 08:59:01 AM
Have you tried the  tag? You could put it right after the image.

There is a cutoff tag?

I did not know that, If I add that at the end of the image, the article will include it?

Have you got the PHP code that creates the article block, so I can customize it?


Damn, I need to update SP in order to take advantage of this cutoff tag, will do that and reply back see how it works


Thanks.
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on April 21, 2010, 09:14:52 AM
I do recommend using the latest release of SimplePortal.  There has been continuous improvement.
 
The [cutoff] tag is very good.  It works with BoardNews (found in PortalBlocks.php) and with portal-page articles display (see PortalArticles.php).  Since these files are all in the zip file, you can get the download and have a look through it even before you do the upgrade.
 
 
Title: Re: Something that can list all topics in a board
Post by: johncccccc on April 21, 2010, 02:19:17 PM
I do recommend using the latest release of SimplePortal.  There has been continuous improvement.
 
The [cutoff] tag is very good.  It works with BoardNews (found in PortalBlocks.php) and with portal-page articles display (see PortalArticles.php).  Since these files are all in the zip file, you can get the download and have a look through it even before you do the upgrade.

I tried to update, but my admin area is very messy with the new 2.3.2 version (gone back to 2.3.1 for now, made support topic too)

Articles option is no good, the idea is when someone posts in that board, it will be automatically linked in the custom page.

Board news option works great, however presentation is not so well, even with the cutoff point tag (I tried while I had 2.3.2 installed).

This image is heavily zoomed out, so you can see it all
(http://i41.tinypic.com/2i1k3mv.png)
I would like several columns and rows, this option only gives me one, I also cannot remove the title or body either

I think I'm running out of options here...

Any other Ideas?
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on April 21, 2010, 02:52:31 PM
First, I thought BoardNews with cutoff might make this a support question.
Now, I think your request is in the correct place. I hope an experienced customizer picks this up.
Here is what I think you've said you want:
   Requirement 2. is where the coding comes in -- replacing the BoardNews logic with gallery-display-like logic, and mashing each post into an identical box. I hope a good customizer picks this up for you.
Title: Re: Something that can list all topics in a board
Post by: johncccccc on April 21, 2010, 03:53:12 PM
First, I thought BoardNews with cutoff might make this a support question.
Now, I think your request is in the correct place. I hope an experienced customizer picks this up.
Here is what I think you've said you want:
 
  • BoardNews content, controlled by [cutoff] tag.
  • Gallery-style display, with perhaps 4-5 blocks per row.
  • Initial image sized appropriately
  • With appropriate "gallery-like" subject and body formatting.
  Requirement 2. is where the coding comes in -- replacing the BoardNews logic with gallery-display-like logic, and mashing each post into an identical box. I hope a good customizer picks this up for you.

Took the word right out of my mouth;

 

In the meantime, Which files would I combine and mix and match to try and create this myself, I'm somewhat familiar with PHP code, I have written a few simple mods for the modsite.

Thanks!
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on April 21, 2010, 06:46:16 PM
You can find all the pre-defined blocks in PortalBlocks.php
Title: Re: Something that can list all topics in a board
Post by: johncccccc on April 25, 2010, 12:11:33 PM
You can find all the pre-defined blocks in PortalBlocks.php

I'm not doing very well at making my own custom block...  :(

shameless bump...
Title: Re: Something that can list all topics in a board
Post by: johncccccc on May 01, 2010, 12:36:05 PM
A few more days has gone by, I'm trying and failing to create this custom block myself...

How do you guys do this crazy stuff...
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on May 03, 2010, 10:48:49 AM
I am not a customizer. But here's how I would approach it.
Since you want to work with boardnews, I'd start with sp_boardnews.
1) Copy the function sp_boardnews into a text editor, like notepad, notepad++ or frontpage. Give it a new name.  Like sp_boxynews, for example
 
2) At the very end of the block, after the closing } of the function, call the function:
 
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 contents of your text editor into a custom php block. Test. Edit one line in the text editor. Copy the whole thing back into the custom php block.  Repeat.
 

4) Here are a some changes you will have to make to get boxes going across.
Below, I show examples using new CSS classes that you can style in portal.css.  You could also choose to use inline styling while you are testing.
Code: (find) [Select]
  $block_parameters = array(
'board' => 'boards',
'limit' => 'int',
'start' => 'int',
'length' => 'int',
'avatar' => 'check',
'per_page' => 'int',
); 
Code: (replace) [Select]
  $block_parameters = array(
'board' => 'boards',
'limit' => 'int',
'start' => 'int',
'length' => 'int',
'avatar' => 'check',
'per_page' => 'int',
'per_row' => 'int',
);

5) Add in the logic to display several posts in a row across the  page
 
Code: (find) [Select]
  foreach ($return as $news)

 
Code: (replace) [Select]
   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>
';

6) Remember to echo </td>, and at the end of the foreach loop block of code, remember to echo a </table> to close your HTML table.

7) Start changing how all that stuff is put inside each boxynews box. Remember to change only one line or two at a time, until you get it the way you want it.
 
If you have more specific questions, you can keep asking here.
Good Luck and have fun!
Title: Re: Something that can list all topics in a board
Post by: johncccccc on May 07, 2010, 12:20:08 PM
Thanks, that has in-sighted me a lot, I should be able to manage that, I will post back for more support if needed and progress :)
Title: Re: Something that can list all topics in a board
Post by: johncccccc on May 10, 2010, 09:04:51 AM
Hi back again...

Im getting a parse error, its on the last line, I have confirmed this with a PHP writing app, which underlines (like spell checkers) where unexpected chars (parse errors) are present, its right at the end, the very end...

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

?>

\
never mind, I got it, I think...

needed to close the 1st { added another } to the end

Code: [Select]
         }}
   
   echo '
      <td>
';

?>

EDIT:

OK now we got that sorted, With no parse errors, related to errors stated above anyway, Im still having issues, I have fatal errors, including PortalBlocks.php, Do I need to add this code to PortalBlocks.php too? ???
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on May 10, 2010, 09:26:37 AM
There is no reason to add this code to PortalBlocks.php.
The fragment of code you show does not not include most of what the original subroutine does.  You are asking it to show the contents of $news, for example, but there is nothing in $news (according to the fragment you are showing).
 
Is this the entire subroutine you are trying to use?
 
Title: Re: Something that can list all topics in a board
Post by: johncccccc on May 10, 2010, 10:13:33 AM
I'm lost, I thought I could manage it, guess not lol

I think I'm not adding the function at the end like you said above..

Quote
2) At the very end of the block, after the closing } of the function, call the function:

Maybe this is the problem...
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle 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.
 
Title: Re: Something that can list all topics in a board
Post by: johncccccc 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 ?>
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle 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 * (#post_footnote)
 
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 (http://devzone.zend.com/article/627) or http://php.net/manual/en/tutorial.php (http://php.net/manual/en/tutorial.php)
or even a Python tutorial
Title: Re: Something that can list all topics in a board
Post by: johncccccc 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?
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle 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.

 
 
 
 
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle 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);
Title: Re: Something that can list all topics in a board
Post by: johncccccc 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
(http://i49.tinypic.com/2hfuwrk.png)

1. Enable cutoff point
2. Fix the alignment

Were done :D
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle 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.
Title: Re: Something that can list all topics in a board
Post by: johncccccc 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 :)
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle 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!
 
 
Title: Re: Something that can list all topics in a board
Post by: johncccccc 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 :)
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle 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.
Title: Re: Something that can list all topics in a board
Post by: johncccccc 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?
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle 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?
Title: Re: Something that can list all topics in a board
Post by: johncccccc 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.
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle 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
 
 
 
Title: Re: Something that can list all topics in a board
Post by: johncccccc 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

(http://i45.tinypic.com/24b0oyg.png)

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
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle 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
 
Title: Re: Something that can list all topics in a board
Post by: johncccccc 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 :)
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle 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  :)
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 07, 2010, 12:04:42 PM
I'm very glad to help you figure some of this out.
With a little reading, you will be an expert in no time  :)

Speaking of experts, I think I've found out 1st bug...

The page links are not working correctly, currently there are 6 reviews, I set 4 per page, 2 per row, thus creating a 2nd page., clicking page 2 results with the 1st page still been displayed, however the address bar does change to " mysite.com/reviews??sa=news;start=4 ", to me it looks a little off, but I don't know where.

Any Ideas?
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on June 07, 2010, 12:45:17 PM
Not me! I forgot about an already-reported bug that will be fixed in the next version of SimplePortal.  :-[
Code: (find) [Select]
$page_index = constructPageIndex($current_url . '?sa=news', $start, $limit, $per_page);
Code: (replace) [Select]
$page_index = constructPageIndex($current_url . 'sa=news', $start, $limit, $per_page);

I updated the attachment to http://simpleportal.net/index.php?topic=5248.msg33656#msg33656 (http://simpleportal.net/index.php?topic=5248.msg33656#msg33656)
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 07, 2010, 01:50:03 PM
hmm..

I uploaded your attachment and manually checked it, for the new change.

I does not change anything, I even cleared the cache too, should it be something like " ?sa=boxynews', " etc etc
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on June 07, 2010, 02:03:10 PM
If your browser won't give you the new one, please do the manual edit I gave above.
 
 
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 07, 2010, 02:07:14 PM
hmmm, still no difference, however the address bar has now changed to " mysite.com/reviews?sa=news;start=4 "
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on June 07, 2010, 05:44:47 PM
I would expect something more along the lines of mysite.com/index.php?sa=news;start=4 or mysite.com/reviews/index.php?sa=news;start=4, depending on where your forum and portal are located.
 
I've only tested this out on one site, both with and without search-friendly URLs. I'm not seeing this problem.
 
If the page index is wrong, the problem is occcuring around
Code: [Select]
$page_index = constructPageIndex($current_url . 'sa=news', $start, $limit, $per_page);because that is where those page indices are made up.
 
My question is -- what is $current_url.
Before you click on one of the pagination links, what is the URL in the address bar?
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 07, 2010, 06:50:23 PM
The block is on a simple portal page, the page is called reviews, I have setup a .HTaccess for that, so the URL can look nice

mysite.com/index.php?page=reviews is the absolute location, where my HTaccess file has the rewrite for it to make it mysite.com/reviews

maybe this is the issue...

/me goes to test it...

And what do you know, that is the problem...

Any ideas about me having my cake and eating it too?

I would like to keep the URL rewrite for the reviews page, but I want the page links to work too, any workaround?

maybe something like
Code: [Select]
$page_index = constructPageIndex($boardurl . index.php . 'sa=news', $start, $limit, $per_page);
tried also
Code: [Select]
$page_index = constructPageIndex($boardurl . 'echo /index.php?page=reviews', 'sa=news', $start, $limit, $per_page);
no good :(
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on June 07, 2010, 08:09:36 PM
This is now hard-coded, so  it is only going to work on your portal page.
If you ever want boxynews on another page, you will have to revisit what goes in here.
Code: [Select]
$page_index = constructPageIndex($scripturl . '?sa=news', $start, $limit, $per_page);
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 07, 2010, 10:48:18 PM
That takes me to the portal page, the URL I need it to link to is

http://www.mysite.com/index.php?page=reviews;start=4

I managed to make it somewhat work in my own crude way

I got serttings.php added another var " $reviewpage = 'http://www.mysite.com/index.php?page=reviews;start=4'; "

then in boxynews.php I made $reviewpage global then changed the $currenturl page of the page index code to $reviewpage and to my amazement it actually work, would this method be efficial?

I used this code and it works perfectly

Code: [Select]
$page_index = constructPageIndex($reviewpage, $start, $limit, $per_page);
somehow removing the " 'sa=news' " completely fixed everything

EDIT 2


a bonus, no errors in log either :D

Now Finally I think were done here :)

Thanks alot!



Now for some tweaks, (to make it less of board news and more about the review board)

Read More | Write Comment,
I would like to change these too the following
Read Review | Comment on this Review.

I searched boxynews.php found "read more" changed it and nothing.. didn't find "write comment".

How would I do this?
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on June 07, 2010, 11:47:20 PM
hmmm. You probably don't need to mess around with settings.php.
Code: [Select]
$reviewpage= $scripturl . '?page=reviews;';
$page_index = constructPageIndex($reviewpage . 'sa=news', $start, $limit, $per_page);

I think you are correct, that the ";sa=news" part is not strictly necessary, as long as you've got ";start=<something>" in there. On the other hand, you don't need ";start=4;start=8" and ";start=4;start=0" in the URL.
 
This hack was necessary because SMF doesn't know about the .htaccess trick you used, so SimplePortal can't figure out how to make up the correct URL. I'm sure there is a more elegant way to figure out what the current URL is supposed to be.  I'm sure you could learn more by creating a custom php block on that page (for admin's eyes only, of course) containing only
Code: [Select]
phpinfo();
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 07, 2010, 11:53:03 PM
Im happy with it, as long as its not a security risk.

I figured out how to change the "Read More" to "Read Review", I did it right too, I added another strong to Sportal.english.php language file, then changed boxynews.php to  " $txt['sp_read_review'] "  I however cannot find the language string for "Write Comment".

Any Ideas where that is?
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on June 08, 2010, 12:36:18 AM
Code: [Select]
<div class="sp_right">', $return[$i]['link'], ' ',  $return[$i]['new_comment'], '</div>
and of course 'new_comment' gets set above in
Code: [Select]
'new_comment' => !empty($row['locked']) ? '' : '| <a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>',

So you can change the value of $txt['ssi_write_comment'], or create another strong string.
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 08, 2010, 10:02:31 AM
I had a feeling it was that one, but I never saw the language string "Write Comment" so I was weary about changing anything
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on June 08, 2010, 10:36:31 AM
Remember -- anything you change in this block or in your own personal php file will stay that way through any SimplePortal and SMF upgrades.
 
Anything you change in a SimplePortal file will get lost in the next SimplePortal upgrade.
Anything you change in an SMF file *MIGHT* get lost in the next SMF upgrade.
 
It is pretty safe to test just replacing things within this function, because it won't affect anything about SMF or SimplePortal works.
 
So I would recommend just putting your changes in the block or in the boxynews file.
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 08, 2010, 02:41:00 PM
what about creating a reviewspage.english.php file and add that, then add my language strings there for the entire boxynews.php ?

This way I can do it right and keep it after upgrades. (I think)

I found the "Write Comment" part for now its hard coded in the boxynews.php file, I may do the above in the future, although appearance-wise there will be no difference...
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on June 08, 2010, 03:53:50 PM
Because boxynews.php is only meant to be used for one block on one forum, and because you don't intend to package it up as a mod to share with others, I would recommend keeping things as simple as possible.
 
If it were me, I would put all the boxynews stuff into one file.
 
If you want to rename the file to "reviewsblock.php", and rename the function to "sp_reviewsblock" to help you keep track of it, go ahead.
Whatever keeps it simple and easy to keep track of.
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 08, 2010, 05:56:59 PM
Yea, that sounds easier, after all this work making it right I would like to add the CSS changes also in the file or in the block code, how can we do this, to make it even more simpler for future use?
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on June 08, 2010, 07:19:31 PM
The easiest thing to do with CSS changes is to put them into portal.css and keep good notes.
 
They cannot go into the file or into the block code, unfortunately. That is because they have to linked/loaded between the <head></head> tags, which have long been closed by the time the block output is called.
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 08, 2010, 07:33:35 PM
Darn, oh well, I guess that's as simple as it can get then,

Well for now, I think this is complete

Now to see whether its fit for a future additional block for the simple portal team to use.

It would be down to you though, after all, you created the whole thing lol.
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on June 08, 2010, 07:51:30 PM
Well, it is available on this thread for anyone who wants it.
 
If you think it is a valuable feature, you are welcome to re-post the code and the suggestion to the feature request board. But since there aren't a ton of users begging for information on how they can use this block, I doubt it is going to get added.  If I were clever and had a bit of extra time, I'd learn how to package it up into a mod.  But I'm not going to do that now.  In about a week, I'm afraid I'm going to run out of time to help at SimplePortal.
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 08, 2010, 08:32:12 PM
Well I've actually made mods which use custom tabs with there own pages, which also create the php file in the sources directory, just adding that into it would to the trick, there is a smf package maker which can make the package for you :)

A list of my mods below
http://custom.simplemachines.org/mods/index.php?action=profile;u=187539 (http://custom.simplemachines.org/mods/index.php?action=profile;u=187539)
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 18, 2010, 12:57:43 PM
Can one of the Simple Portal developers please review the code in the PHP file attached by AngelinaBelle and tell me If I will be allowed to use it in a mod I'm working on for the mod site?

attachment:
http://simpleportal.net/index.php?topic=5248.msg33656#msg33656

Thanks.
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on June 18, 2010, 01:49:29 PM
Well -- I did all that coding, but then couldn't be bothered to figure out how to turn it into a mod package.  So I'll give you permission to take that code, turn it into a mod package, share, and support it.  :).
 
I'll be happy if you simply credit me with writing the code the mod is based on.
I won't be around enough in the near term to help support or improve it in any way, however.
 
Enjoy!
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 18, 2010, 01:54:09 PM
WooHoo, ok, well im off too see what I can do with it then :D

Thanks
Title: Re: Something that can list all topics in a board
Post by: Nothingness on June 23, 2010, 01:46:09 AM
Not me! I forgot about an already-reported bug that will be fixed in the next version of SimplePortal.  :-[
Code: (find) [Select]
$page_index = constructPageIndex($current_url . '?sa=news', $start, $limit, $per_page);
Code: (replace) [Select]
$page_index = constructPageIndex($current_url . 'sa=news', $start, $limit, $per_page);

I updated the attachment to http://simpleportal.net/index.php?topic=5248.msg33656#msg33656 (http://simpleportal.net/index.php?topic=5248.msg33656#msg33656)
Thank you, I have to search "pagination" and I landed here. :P
Saved me from creating another topic on it.
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on June 23, 2010, 06:32:26 AM
johncccccc --
 
I didn't mean to imply that my permission to use my code is the same as SimplePortal's permission to use SimplePortals code.
But I am afraid that my previous posting reads that way. I am not a SimplePortal decision-maker, and not in a position to give permission to distribute copyrighted code.
 
Before you submit the mod at SimpleMachines.org, please request permission. This could save you hassles later, and will buy you good will now.  You can see the team listing at http://simpleportal.net/index.php?action=team (http://simpleportal.net/index.php?action=team).  It might be a good idea to contact project manager Eliana Tamerin.
Title: Re: Something that can list all topics in a board
Post by: johncccccc on June 23, 2010, 04:09:42 PM
Can I use the code in your attachment, that's all I plan on using?
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on August 09, 2010, 01:06:18 PM
Sorry to be so long getting back to you. I've been away.
 
You have my permission to use all the code I have written on this little customization.
 
Most of the code that appears in my attachment was created by SimplePortal developers.
 
I think your best plan is to contact Eliana Tamerin for permission.  She's the project manager here.
 
Title: Re: Something that can list all topics in a board
Post by: TrickyRicky on December 11, 2013, 05:50:34 PM
This is fantastic.
Title: Re: Something that can list all topics in a board
Post by: radu81 on March 18, 2014, 06:03:21 AM
thank you AngelinaBelle ;)
Title: Re: Something that can list all topics in a board
Post by: AngelinaBelle on March 26, 2014, 05:18:06 PM
I am so glad to help.
Mind you -- that code is awfully old now.  Please check that it still works with current versions of SMF and SimplePortal.
SimplePortal 2.3.8 © 2008-2024, SimplePortal