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: 388
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

NEED HELP? If you're looking for support with Simple Portal, look no further than the Support Board!

Author Topic: Block Request: Recent Topics With First Attachment Thumbnail  (Read 12390 times)

0 Members and 1 Guest are viewing this topic.

Offline tanks

  • Semi Newbie
  • *
  • Posts: 14
  • SMF Version: 2 RC1
  • SP Version: 2.2.1
Okey so i run a movie board and i would love to have a block that would show recent topics from one board. But instead of icons it would show the thumbnail of the first attachment for each topic.

Is this even possible ?  8)

Offline tanks

  • Semi Newbie
  • *
  • Posts: 14
  • SMF Version: 2 RC1
  • SP Version: 2.2.1
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #1 on: May 11, 2009, 06:14:32 AM »
Sorry for the bumb, but is this possible ?  :nervous-happy:

Offline kai920

  • Semi Newbie
  • *
  • Posts: 39
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #2 on: July 27, 2009, 01:40:01 PM »
I'm looking for something like this as well. Just looking to spice up the frontpage of the portal a bit by including images. I'm sure it's possible as I have done something similar for Joomla + SMF, but I'm new to Simple Portal.

- which file(s) would I need to edit?
- should I create a new block, based off of the default "Board News" block?

Offline kai920

  • Semi Newbie
  • *
  • Posts: 39
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #3 on: July 28, 2009, 12:30:18 PM »
I'm experimenting with SMF Media Gallery (SMG) from http://smf-media.com/

So far the linked images using the [smg id=xx] tags show up on the frontpage of the portal, which is fantastic!

Offline timour_2

  • Newbie
  • Posts: 2
  • SMF Version: 1.1.10
  • SP Version: None
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #4 on: November 19, 2009, 04:41:24 PM »
I found this somewhere on the net


here it goes:



1) Search for your function ssi_boardNews and replace the whole function with this :

Code: [Select]
function ssi_boardNews($board = null, $limit = null, $start = null, $length = null, $output_method = 'echo')
{
global $scripturl, $db_prefix, $txt;
global $settings, $modSettings, $context;

loadLanguage('Stats');

// Must be integers....
if ($limit === null)
$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
else
$limit = (int) $limit;

if ($start === null)
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
else
$start = (int) $start;

if ($board !== null)
$board = (int) $board;
elseif (isset($_GET['board']))
$board = (int) $_GET['board'];

if ($length === null)
$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
else
$length = (int) $length;

// Make sure guests can see this board.
$request = db_query("
SELECT ID_BOARD
FROM {$db_prefix}boards
WHERE " . ($board === null ? '' : "ID_BOARD = $board
AND ") . "FIND_IN_SET(-1, memberGroups)
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) == 0)
{
if ($output_method == 'echo')
die($txt['smf_news_error2']);
else
return array();
}
list ($board) = mysql_fetch_row($request);
mysql_free_result($request);

// Find the posts.
$request = db_query("
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, m.ID_MSG
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_BOARD = $board
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY m.ID_MSG DESC
LIMIT $start, $limit", __FILE__, __LINE__);
$return = array();
$message_ids = array();
while ($row = mysql_fetch_assoc($request))
{
$message_ids[] = $row['ID_MSG'];
// If we want to limit the length of the post.
if (!empty($length) && strlen($row['body']) > $length)
{
$row['body'] = substr($row['body'], 0, $length);

// The first space or line break. (<br />, etc.)
$cutoff = max(strrpos($row['body'], ' '), strrpos($row['body'], '<'));

if ($cutoff !== false)
$row['body'] = substr($row['body'], 0, $cutoff);
$row['body'] .= '...';
}

$row['body'] = doUBBC($row['body'], $row['smileysEnabled']);

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

  $return[$row['ID_MSG']] = array(
'attachments' => array(),
'id' => $row['ID_TOPIC'],
'icon' => '<img src="' . $settings['images_url'] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" />',
'subject' => $row['subject'],
'time' => timeformat($row['posterTime']),
'timestamp' => $row['posterTime'],
'body' => $row['body'],
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['numReplies'] . ' ' . ($row['numReplies'] == 1 ? $txt['smf_news_1'] : $txt['smf_news_2']) . '</a>',
'replies' => $row['numReplies'],
'new_comment' => '<a href="' . $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . '">' . $txt['smf_news_3'] . '</a>',
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'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['posterName'] . '</a>' : $row['posterName']
),
'is_last' => false
);
}
mysql_free_result($request);



if (empty($return))
return $return;

// Find their attachments.

$request = db_query("
SELECT ID_ATTACH, ID_MSG, filename, size, downloads
FROM {$db_prefix}attachments
WHERE ID_MSG IN (" . implode(', ', $message_ids) . ")", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))

{
$return[$row['ID_MSG']]['attachments'][] = array(
'name' => $row['filename'],
'downloads' => $row['downloads'],
'size' => round($row['size'] / 1024, 2) . ' ' . $txt['smf211'],
'byte_size' => $row['size'],
'href' => $scripturl . '?action=dlattach;topic=' . $return[$row['ID_MSG']]['id'] . '.0;id=' . $row['ID_ATTACH'],
'link' => '<a href="' . $scripturl . '?action=dlattach;topic=' . $return[$row['ID_MSG']]['id'] . '.0;id=' . $row['ID_ATTACH'] . '">' . $row['filename'] . '</a>'
);
}
mysql_free_result($request);
return $return;
}



Now you can pull out attachments.

php block :   2) Second step is easy, I managed to edit the script so the result you want (and I) is done.

Code: [Select]
$array_boardNews = ssi_boardNews(7.0, 3, null, 'array');
foreach ($array_boardNews as $news)
{
$newsImage = '' ;
if( isset( $news[ 'attachments' ][ 0 ] ) )
{
$newsImage = '<img class="news" src="' . $news[ 'attachments' ][ 0 ][ 'href' ] . ';image" alt="' . $news[ 'attachments' ][ 0 ][ 'name' ] . '" title="' . $news[ 'attachments' ][ 0 ][ 'name' ] . '" width="100" height="100"/>' ;
}
echo '<a href="'.$news['href']. '">
<div class="teaser">
<div class="teasercontent">
<h1 class="news">' . $news['subject'] . '</h1>' . $newsImage. '
</div>
<div class="teaserfooter">
</a></div>
</div>
';
}


All you have to do is editing this line :
$array_boardNews = ssi_boardNews(7.0, 3, null, 'array');

7.0 = The board out of which topics + attachments are taken.
3 = the number of how many topics (together with their images) should been shown.
That's all you have to edit.

Offline timour_2

  • Newbie
  • Posts: 2
  • SMF Version: 1.1.10
  • SP Version: None
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #5 on: November 19, 2009, 04:44:53 PM »
It shows topic and the first attachment :nervous-happy:

Now, is it possible to show first 100+ words of the topic?
Can anyone help? I've been looking for this for a long time now... Hope someone will manage to do it :thumbsup:



I'VE FIGURED IT OUT
in case someone needs it as well:
Code: [Select]
$array_boardNews = ssi_boardNews(1, 3, null, 50, 'array');
foreach ($array_boardNews as $news)
{
$newsImage = '' ;
if( isset( $news[ 'attachments' ][ 0 ] ) )
{
$newsImage = '<img class="news" src="' . $news[ 'attachments' ][ 0 ][ 'href' ] . ';image" alt="' . $news[ 'attachments' ][ 0 ][ 'name' ] . '" title="' . $news[ 'attachments' ][ 0 ][ 'name' ] . '" width="100" height="100"/>' ;
}
echo ' </font>
<div class="teaser">
<div class="teasercontent">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<!-- MSTableType="layout" -->
<tr>
<td width="119" valign="top"><a href="'.$news['href']. '">
<font size="2">' . $newsImage. ' </font>
</a></td>
<td valign="top"><font size="2"><a href="'.$news['href']. '">
' . $news['subject'] . '</a></font><br>
' . $news['body'] . '</td>
</tr>
</table>
</div>
<div class="teaserfooter">
</a></div>
</div>
';
}
 


And this of course goes to PHP block
« Last Edit: November 20, 2009, 03:18:15 PM by timour_2 »

Offline motorhed

  • Semi Newbie
  • *
  • Posts: 6
  • SMF Version: 2.0.2
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #6 on: April 24, 2012, 10:17:22 PM »
Sorry for resurrecting an old topic, but this is exactly what I need for my forum/portal...

However, it doesn't work for me. :ill: lol


Is this compatable with 2.0.X?

Offline motorhed

  • Semi Newbie
  • *
  • Posts: 6
  • SMF Version: 2.0.2
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #7 on: April 25, 2012, 02:48:22 AM »
Forgot to mention, this is 'sort of an emergency', ha ha. Basically it's the only thing standing in the way of effectively 'launching' my site. I want to have this nailed down before opening, etc.

I don't expect that means anyone will drop everything and rush to this, but I wanted to mention.

Offline andy

  • On Leave
  • *
  • Posts: 861
  • Gender: Male
    • Outdoor Club Japan (OCJ) アウトドア・クラブ・ジャパン
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
  • Elkarte Version: None
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #8 on: April 25, 2012, 09:13:45 AM »
Im busy right now and not a coder anyway...

Quote
Is this compatable with 2.0.X?
You need to test it really.


There was a similar request recently - last 1 or 2 months. So if you look through the custom coding/block requests Im sure you will find it.
Other than that  maybe wait till a programmer is not so busy. There might be someone interested in customizing - paid  work - if it is that important. And they have time...
Everyone is a volunteer here so please try and make a small donation to keep the Simple Portal website running


Offline motorhed

  • Semi Newbie
  • *
  • Posts: 6
  • SMF Version: 2.0.2
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #9 on: April 25, 2012, 06:13:35 PM »
Well, I didn't ask you specifically, so I didn't expect you to be a coder or not busy... I'm confused. :D lol


I clearly did test it, hence where I said I couldn't get it to work.

I searched for other discussion on the subject. Naturally, nothing I found seemed to work, or it wasn't presented in a way a novice could impliment it. (IE: Describing general concepts, not providing the find/replace code.)

I've already asked if anyone was interested in doing this for pay on two other forums. However, I found a way to do it myself (but NOT the exact way I want, which is how the mod in this thread sounds like it would work) so I'd rather go with that than pay if it comes down to that choice.
« Last Edit: April 25, 2012, 09:20:41 PM by motorhed »

Offline andy

  • On Leave
  • *
  • Posts: 861
  • Gender: Male
    • Outdoor Club Japan (OCJ) アウトドア・クラブ・ジャパン
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
  • Elkarte Version: None
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #10 on: April 26, 2012, 07:45:55 AM »
Yes, I guess if it failed on a clean, up to date install then it is not compatible.

This is all I can find to help. After that your way or perhaps try asking in customization.

http://simpleportal.net/index.php?topic=10766
Everyone is a volunteer here so please try and make a small donation to keep the Simple Portal website running


Offline motorhed

  • Semi Newbie
  • *
  • Posts: 6
  • SMF Version: 2.0.2
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #11 on: April 26, 2012, 08:03:47 PM »
Unfortunately I can't use that. The float BBC tag doesn't call the first post attachment, it requires the poster to purposefully put the image in. I need it to be automatic because you can't always rely on people to add the BBC code the way the webmaster prefers.

Don't worry about trying to 'fix' the problem, I just need someone who knows to tell me if this is supposed to work with 2.0.X

I can then proceed depending on their answer.


It needs to be clear that the solution to this issue is to provide (or explain) what was originally asked for, not supply unrelated Mods that don't do what's asked.

Offline andy

  • On Leave
  • *
  • Posts: 861
  • Gender: Male
    • Outdoor Club Japan (OCJ) アウトドア・クラブ・ジャパン
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
  • Elkarte Version: None
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #12 on: April 26, 2012, 09:20:07 PM »
Just doing what I can to help as getting things exactly to requirements might not be so easy ....
Quote
Forgot to mention, this is 'sort of an emergency',

If you want it exactly your way then I guess you require custom code:
http://simpleportal.net/index.php?board=39.0

Unless a coder picks this up and decides to make  (or fix this) block there is no other option.

I will leave you to it then - good luck.
Everyone is a volunteer here so please try and make a small donation to keep the Simple Portal website running


Offline motorhed

  • Semi Newbie
  • *
  • Posts: 6
  • SMF Version: 2.0.2
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #13 on: April 27, 2012, 01:12:38 AM »
If the code in this thread works with 2.0.X and I'm just making a mistake implimenting it, then I don't need custom code, right?

As for the quote, this followed...

I don't expect that means anyone will drop everything and rush to this, but I wanted to mention.

Offline motorhed

  • Semi Newbie
  • *
  • Posts: 6
  • SMF Version: 2.0.2
Re: Block Request: Recent Topics With First Attachment Thumbnail
« Reply #14 on: April 29, 2012, 04:09:10 PM »
I give up. The code in this thread does not work with 2.0.X, for any future users who may find this topic.