News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Adding Custom Image for boardNews Topics

Started by isara, January 28, 2008, 08:35:09 PM

Previous topic - Next topic

isara

Hello SMF,

I would like to add a custom image next to each topic (not board) using the ssi_boardNews function and smf_recentTopics mod. Once a new topic is created I will upload a small image to a forum folder, using the number for the topic just created as the filename (ex: 2505.gif). Then it will show up next to the topic information on our homepage and hopefully get more attention.

Here is my site. The boardNews is the orange section on the right (Charity Projects):
http://www.isara.org

Also, I have tried placing a "new" image next to the boardNews topics on the homepage but cannot get it to work.

Here is some of my SSI code:

// Check that this message icon is there...
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']);

$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['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'body' => $row['body'],
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new" style="font-weight:normal">' . $row['numReplies'] . ' ' . ($row['numReplies'] == 1 ? $txt['smf_news_1'] : $txt['smf_news_2']) . '</a>',
'replies' => $row['numReplies'],
'comment_href' => !empty($row['locked']) ? '' : $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . ';num_replies=' . $row['numReplies'],
'comment_link' => !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . ';num_replies=' . $row['numReplies'] . '" style="font-weight:normal">' . $txt['smf_news_3'] . '</a>',
'new_comment' => !empty($row['locked']) ? '' : '<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'],
'new' => !empty($row['isRead']),
'href' => !empty($row['ID_MEMBER']) ? $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] : '',
'link' => !empty($row['ID_MEMBER']) ? '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new" style="font-weight:normal">Last ' . $txt[525] . ' ' . $row['posterName'] . '</a>' : $row['posterName']
),
'locked' => !empty($row['locked']),
'is_last' => false
);
}
mysql_free_result($request);

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

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

if ($output_method != 'echo')
return $return;

foreach ($return as $news)
{
echo '<div style="padding-left:5px"><img src="images/bullet.gif" alt="" /> <a href="', str_replace(array("?","topic="),array("","topic,"),$news['href']), '">', str_replace(array("Re:"),array(""),$news['subject']), '</a>';

if ($news['new'] && $context['user']['is_logged'])
echo '<img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" />';

echo '</div><div style="padding-left:5px;color:#FF9900"><img src="images/forum-comment.gif" style="vertical-align:middle" alt="" /> ', str_replace(array("?","topic="),array("","topic,"),$news['link']), $news['locked'] ? '' : ' | <img src="images/forum-last.gif" style="vertical-align:middle" alt="" /> ', str_replace(array("?","topic="),array("","topic,"),$news['poster']['link']), ' | <img src="images/forum-post.gif" style="vertical-align:middle" alt="" /> ', str_replace(array("?",";","action=","topic=","num_replies="), array("","/","action,","topic,","num_replies,"),$news['comment_link']), '</div>';

if (!$news['is_last'])
echo '
<div style="margin:2px;border-bottom:1px dotted #FF9900" /> </div>';
}
}


Thanks in advanced for any help you can provide,
PK

isara

#1
Figured out a solution to the first issue. Here's the code.

<a href="', str_replace(array("?","topic="),array("","topic,"),$news['href']), '"><img src="images/forum/', $news['id'], '.gif" border="0" alt="" /></a/

Still need help with the "new" image for topics. Any ideas?

kai920

Hey,

I really like what you've done with the custom frontpage image.  Do you resize them to fit manually before uploading? I wonder if this can be set to automatically resize somehow using php.

By the way, if you dont mind me asking - how have you set up IsaraPIX? Is this a custom mod? I love how the images are thumbnails inside forum posts. Really helps to keep the size of the post down.

Thanks!

isara

Hi kai920 - Thanks! I've been working a lot on the homepage design lately (had many suggestions from our visitors and members). ;D Your site is looking nice too. The image rotator you have on their now is great. We had it before and our visitors really liked it. Unfortunately we had to remove it because it was making the homepage load too slowly and since we want people to use our site as their homepage we had to make the site load as quickly as possible. But your site looks great!

The Isara Feature Project section is just a "Random Image" script (about 1k in size) using a PHP include and a text file that has all the html code. The images were all created/sized individually in Photoshop to fit the block of space. We only have three Projects in the random rotation now. When I have some more time I'll add some more stories/images to the text file so our visitors don't get bored seeing the same stuff again and again. lol

IsaraPIX uses a free PHP image hosting script. It is basically the same as Imageshack. It will host images and provide users with bbcode to place inside forum topics. Unfortunately it won't do bulk uploads. Trying to think of ways to better connect IsaraPIX with the main Isara forum. Any ideas?

Thanks again for your post. I really appreciate it. Good luck with your site.
-pk

kai920

hi PK,

I've been trying to re-orient my site around SMF. You may have seen one of my other posts about my struggle between staying with Joomla (actually, migrating to Mambo) and Tinyportal.  Is your site running on Joomla or Mambo?  Also, I can't figure out if you are running SMF with a bridge or standalone! It seems you have some kind of SEF URLs for SMF set up.  I also *just* saw your profile page... wow, lots of good stuff you have going on. If you don't mind I'm going to bookmark your site for some inspiration from time to time :)

My frontpage slideshow is a bit heavy, yep... I've been thinking of using that to point to SMF posts of note, instead of it pointing to Joomla articles. There also seem to be other lighter-weight alternatives around from the various "professional" template developers.

Coincidentally I came across this recent article that details how to set up a PHP image hosting script. Would yours be one of those mentioned by any chance? I do wonder though: are there any problems with bots or people uploading bogus/unwanted/adult material?

I've been wondering how to solve the image issue for users as well, instead of hotlinking from other sites. Attachments work, but most of the time having them display inline is more useful. On phpBB3 (which forum.joomla.org converted to) they have the ability to upload directly through a post *and* place images inline. I might suggest a SMF gallery mod which would cut down on the bogus images, but I see you've got something similar set up in your advanced profiles.  If you come across any new ideas, let me know.

OBAMA

this is great,
could this work outside joomla?

Advertisement: