TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,019
  • Total Topics: 21,332
  • Online today: 1,062
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 432
  • Total: 432

board picture for forum-posts on frontpage

Started by Mooztik, October 05, 2009, 07:14:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mooztik

hi,

due to the need to add more than 5 boards pickup for frontpage display, i've made some hacks to add the possibility to assign an image to each board selected.
the reason is simple,  the user know what kind of topic (discution theme board) is about.

this is the parts of code modified :

i've added an sql entry to store images list

INSERT INTO `smf`.`smf_tp_settings` (`id` ,`name` ,`value`)
VALUES (NULL , 'SSI_boardimg', NULL);





// file : TPortalAdmin.template.php

// after line 967 (modified board selection)

// add specific image/logo for each board
if(!is_array($context['TPortal']['articons']['illustrations'] ))
{
tp_collectArticleIcons();
}
echo '<table border="0" cellpadding="0" cellspacing="5" width="100%">
';
//board 1
echo '<tr><td align="right" width="250" height="70" valign="top">
<select size="1" name="tp_ssiboard1">';
$tn=sizeof($context['TPortal']['boards']);
for($n=0 ; $n<$tn; $n++){
echo '
<option value="'.$context['TPortal']['boards'][$n]['id'].'" ' ,$context['TPortal']['boards'][$n]['id']==$context['TPortal']['SSI_board1'] ? 'selected' : '' , '>'.$context['TPortal']['boards'][$n]['name'].'</option>';
}
echo '
</select>
<select size="1" name="tp_ssiboardimg1" onchange="changeIllu(document.getElementById(\'tp-illu1\'), this.value);">
<option value="0">',$txt['tp-none-'],'</option>
';
foreach($context['TPortal']['articons']['illustrations'] as $key =>$value)
{
echo '<option value="'.$value['file'].'" '.( $value['file'] == $context['TPortal']['SSI_boardimg1']? 'selected="selected"' : '').'> '.$value['file'].' </option>
';
}

echo '
</select></td><td align="left"><img width="64" height="64"  id="tp-illu1" src="'.$boardurl.'/tp-files/tp-articles/illustrations/'.$context['TPortal']['SSI_boardimg1'].'"/>
</td></tr>';



then repeated for each board selection




// file : TPortalAdmin.php
// line : 1388, after tp_sisboard assignation,


elseif($what=='tp_ssiboardimg1')
{
$bo=array();
$bo[0]=$_POST['tp_ssiboardimg1'];
$bo[1]=$_POST['tp_ssiboardimg2'];
$bo[2]=$_POST['tp_ssiboardimg3'];
$bo[3]=$_POST['tp_ssiboardimg4'];
$bo[4]=$_POST['tp_ssiboardimg5'];
$value=implode(',',$bo);
tp_query("UPDATE " . $tp_prefix . "settings SET value='$value' WHERE name='SSI_boardimg'", __FILE__, __LINE__);
$go=6;
}




// file : TPmodules.php
// line : 1710  after message icons

// mooztik zone :) assign board image
$boardimgs = explode(',',$context['TPortal']['SSI_boardimg']);
$boardid = explode(',',$board);
foreach($boardid as $key=>$value)
{
$boards[$value] = $boardimgs[$key];
}

// ...
// the 'find the posts' request , modified, added
// T.ID_BOARD before the FROM (get board id to assign image)

//...
// added at the end of the big $return[$now] array
'illustration' => (strlen($boards[$row['ID_BOARD']])>3 ? $boards[$row['ID_BOARD']] : '')



thats'all, (i hope not forget parts of code)

then , when you select 'picture+article' in the layout types, the image assigned to the board appears in replacement of the default 'newspaper' image.


next hack, adding a day limit on displaying post topic

bloc

Thats rather clever lol. :)

You will perhaps be interested to know that TP 1.0 beta 5 can actually use attached images(the thumbnail anyway) instead of the "illustrations" for forum posts. In practice by attaching a image you can provide a picture on the spot.

Its only used in layout 4 though.

Mooztik

#2
thank's ^^
Quote
You will perhaps be interested to know that TP 1.0 beta 5 can actually use attached images(the thumbnail anyway) instead of the "illustrations" for forum posts. In practice by attaching a image you can provide a picture on the spot.

Its only used in layout 4 though.
it's a good news, and a good complement to my hack,Give the possibility for the poster to override default board image :D

i'm lookin to add the same modification for icon+article layout ^^ and add a day limit (a post older than the limit, is not displayed)

Mooztik

hello again

i've made a mod file to simplify the hack for those who interested in.

please be warned this file and modifications are not official/supported. you use it at your own risks.
please don't apply this mod file with SMF, make modifications manually to ovoid any risks of bad MOD file architecture (i m new on SMF, and not sure on the good code writing)
do not forget to insert the 2 needed sql entries, or the hack simply not work...
images need to have 128 pixels sides.

modifications :

  • extend from 5 to 10 board selection
  • each board selected can be have an illustation assigned to it
  • to simplify illutration selection, this hack uses the articles illustrations, to add an image simply go to the articles admin section and add an illustration
  • added a day time limit. if you use it, a post older than this timelimit is not displayed on front page

limitations :

  • currently only support default theme and english non-utf8 language

post here if you have any ideas, improvments .


This website is proudly hosted on Crocweb Cloud Website Hosting.