How (where) can I use this code:
<img src="' . $settings['images_url']. '/topic/nav.gif" width="13" height="11" border="0" alt="" /></td>
in this code:
echo '
<table>
<tr>
<td>';
global $scripturl;
$what=ssi_recentTopics('5', NULL, 'array');
echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3"><td valign="middle"><font color="#4266BB">ÃŽÂÃŽÂα μηνÃÂμαÄα </font></td></tr>';
foreach ($what as $topic)
{
echo '<tr><td class="windowbg" valign="middle">
', $topic['link'];
'</span></td></tr>';
}
in order to have a little image (icon) at the start of every title / topic?
See attached image and thank you once again.
Like this:
echo '
<table>
<tr>
<td>';
global $scripturl;
$what=ssi_recentTopics('5', NULL, 'array');
echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3"><td valign="middle"><font color="#4266BB">ÃŽÂÃŽÂα μηνÃÂμαÄα </font></td></tr>';
foreach ($what as $topic)
{
echo '<tr><td class="windowbg" valign="middle">
<img src="' . $settings['images_url']. '/topic/nav.gif" width="13" height="11" border="0" alt="" />
', $topic['link''] , '</td></tr>';
}
Bloc thanx for the quick reply.
That worked fine.
But I think that I will need more help on that.
Well, I am posting the all block code to see if you can help me to have the arrows showing in all the three tables and to be alinged like in third table.
I can not find a way to make the three tables having the same width too.
Here is the code:
echo '
<table>
<tr>
<td>';
global $scripturl;
$what=ssi_recentTopics('5', NULL, 'array');
echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3"><td valign="middle"><font color="#4266BB">ÃŽÂÃŽÂα μηνÃÂμαÄα </font></td></tr>';
foreach ($what as $topic)
{
echo '<tr><td class="windowbg" valign="middle"><img src="' . $settings['images_url']. '/topic/nav.gif" width="13" height="11" border="0" alt="" />', $topic['link'], '</td></tr>';
}
echo '</table>';
echo '
</td>
<td>';
echo '<table border="0" width="40%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3"><td valign="middle"><font color="#4266BB">ÃŽÂÃŽÂα βιβλία </font></td></tr>';
global $txt;
$it=array();
$it=dl_recentitems('5','date','array');
if(sizeof($it)>0){
foreach($it as $item){
echo '<tr><td class="windowbg" valign="middle">
<a href="'.$item['href'].'">'.$item['name'], '
</a>';
'</span></td></tr>';
}
}
echo '</table>';
echo '
</td>
<td>';
function articles($mode, $limit, $cats, $show_comments, $show_views, $show_rating, $show_time, $show_category, $show_author, $show_articleComment, $output_method) {
// Da Globals!! :P
global $db_prefix, $settings, $scripturl;
// Get the $tp_prefix ready
$tp_prefix = $settings['tp_prefix'];
// The Category time!
$cat = '';
$categories = implode(', ', $cats);
if(!empty($cats))
$cat = "AND a.category IN ($categories)";
// Do all this stuff if Mode is not the 5th one!
// I Believe this will optimize stuff. Well Atleast there is some cutting down in these queries
if($mode != 5)
{
$subcheck = '';
// Get the mode(1-4) parameters ready
if($mode == 1)
{
$m = 'a.date DESC';
}
elseif($mode == 2)
{
$m = 'a.comments DESC';
$subcheck = 'AND a.comments > 0';
}
elseif($mode == 3)
{
$m = 'a.views DESC';
$subcheck = 'AND a.views > 0';
}
elseif($mode == 4)
{
$m = 'a.rating DESC';
}
elseif($mode == 6)
{
$m = 'RAND()';
}
else
$m = 'a.date DESC';
// Well this was the mode and parameters, begin the Queries.
$result = db_query("SELECT
a.id AS atcID, a.date, a.category, a.subject, a.voters,
a.authorID, a.approved, a.off, a.comments, a.views, a.rating, a.useintro,
v.id AS catID, v.value1, v.value2, value3, v.value4, v.value5,
m.realName
FROM
{$tp_prefix}articles AS a
LEFT JOIN {$db_prefix}members AS m ON (m.ID_MEMBER = a.authorID)
LEFT JOIN {$tp_prefix}variables AS v ON (v.id = a.category)
WHERE
a.approved = 1
AND a.off = 0
$cat
$subcheck
ORDER BY $m
LIMIT $limit"
,__FILE__, __LINE__);
// Do da error saving declaration! :P
$items = array();
// And do the next step :D
while ($row = mysql_fetch_assoc($result))
{
// Lets calculate the rating stuff
$rat = array();
$votes = 0;
$total = 0;
$average = 0;
$rat = explode(",", $row['rating']);
$votes = count($rat);
foreach($rat as $mm => $mval)
$total = $total + $mval;
if($votes > 0 && $total > 0)
$average = floor($total / $votes);
// And now lets build up the array
$items[] = array(
'article' => array(
'id' => $row['atcID'], # Article ID
'time' => timeformat($row['date']), # Time the article is posted on
'subject' => $row['subject'], # Article's Subject
'artLink' => '<a href="'.$scripturl.'?page='.$row['atcID'].'">'.$row['subject'].'</a>', # Direct link to article
'comments' => $row['comments'], # No. Of article's comments
'views' => $row['views'], # No. Of article's views
'rating' => $average, # Total Article's rating
'voters' => $votes, # No. of total votes
'is_rated' => !empty($row['rating']), # Is it rated?
'is_categorized' => $row['category'] != 0, # Does it have a category?
),
'author' => array(
'id' => $row['authorID'], # Author ID
'name' => $row['realName'], # Author Name
'link' => '<a href="'.$scripturl.'?action=profile;u='.$row['authorID'].'">'.$row['realName'].'</a>', # Direct link to author
),
'cat' => array(
'id' => $row['catID'], # Cat ID
'name' => $row['value1'], # Cat Name
'link' => '<a href="'.$scripturl.'?cat='.$row['catID'].'">'.$row['value1'].'</a>', # Direct link to category
),
);
}
// Free $result from the evil querys as usual :P
mysql_free_result($result);
// Output method is selected as "array"? Throw the variables back to them
if($output_method == 'array')
return $items;
// Not "array"? Throw the default output out.
$counter = 0;
echo '<table width="100%" border="0" cellspacing="1" cellpadding="4" id="RecentArticlesTBL" class="bordercolor">
<tr align="middle" valign="middle" class="catbg3">
<td colspan="2"><span class="normaltext"><font color="#4266BB">ÃŽÂÃŽÂα άÃÂθÃÂα</font></span></td>';
// Show author column?
if($show_author)echo'
<td><span class="normaltext">Author:</span></td>';
// Show category column?
if($show_category)echo'
<td><span class="normaltext">Category:</span></td>';
// Show the time its posted on column
if($show_time)echo'
<td><span class="normaltext">Published on:</span></td>';
// Show ratings column?
if($show_rating)echo'
<td><span class="normaltext">Ratings:</span></td>';
// Show views column?
if($show_views)echo'
<td><span class="normaltext">Views:</span></td>';
// Show comments column?
if($show_comments)echo'
<td><span class="normaltext">Comments:</span></td>';
echo'</tr>';
foreach ($items as $i)
{
$counter++;
echo '<tr align="left" valign="middle">
<td class="windowbg2">
<img src="' . $settings['images_url']. '/topic/nav.gif" width="13" height="11" border="0" alt="" /></td>
<td class="windowbg"><span class="normaltext">',$i['article']['artLink'],'</a></span>';
echo '';
// Show the author?
if($show_author)
echo '<td class="windowbg2"><span class="normaltext">',$i['author']['link'],'</span></td>';
// Show its category?
if($show_category && $i['article']['is_categorized'])
echo '<td class="windowbg"><span class="normaltext">',$i['cat']['link'],'</span></td>';
// Show the time its posted on
if($show_time)
echo '<td class="windowbg"><span class="normaltext">',$i['article']['time'],'</span></td>';
// Show there ratings?
if($show_rating)
{
// Is it rated?
if($i['article']['is_rated'])
{
echo '<td align="center" class="windowbg2"><span class="normaltext">',str_repeat('<img src="'.$settings['images_url'].'/tpblue.gif" style="width: .7em; height: .7em; margin-right: 2px;" alt="" />', $i['article']['rating']),' (',$i['article']['voters'],' rates)</span></td>';
}
// No?
else
{
echo '<td align="center" class="windowbg2"><span class="normaltext"><i>Not Rated</i></span></td>';
}
// Show the no. of views?
if($show_views)
echo '<td align="center" class="windowbg"><span class="normaltext">',$i['article']['views'],' </span></td>';
// Show the no. of comments?
if($show_comments)
echo '<td align="center" class="windowbg"><span class="normaltext">',$i['article']['comments'],'</a></span></td>';
}
echo '</span></td>';
if($counter < $limit)
echo '';
}
echo '</table>';
}
// Mode is the 5th one?
elseif($mode == 5)
{
// You want the recent comments??
// Yes? Grab em then
// Do the Query
$result = db_query("SELECT
v.*, m.realName, m.ID_MEMBER, a.subject AS aSubject, a.id AS aID,
a.category
FROM
{$tp_prefix}variables AS v
LEFT JOIN {$db_prefix}members AS m ON(m.ID_MEMBER = v.value3)
LEFT JOIN {$tp_prefix}articles AS a ON(a.id = v.value5)
WHERE
v.type='article_comment'
$cat
ORDER BY v.value4 DESC
LIMIT $limit"
,__FILE__,__LINE__);
// Yup, There is always one life saving declaration :p
$comments = array();
// Build up the blocks
while ($row = mysql_fetch_assoc($result))
{
$comments[] = array(
'id' => $row['id'], # Comment ID
'subject' => $row['value1'], # Comment Subject
'time' => timeformat($row['value4']), # Posting Time
'link' => '<a href="'.$scripturl.'?page='.$row['aID'].'#tp-comment">'.$row['value1'].'</a>', # Direct link to the comment
'article' => array(
'id' => $row['aID'], # Article the comment is posted in's ID
'subject' => $row['aSubject'], # The Article's Subject
'link' => '<a href="'.$scripturl.'?page='.$row['aID'].'">'.$row['aSubject'].'</a>', # A direct Link to article
),
'author' => array(
'id' => $row['value3'], # Author's ID
'name' => $row['realName'], # Author's Name
'link' => '<a href="'.$scripturl.'?action=profile;u='.$row['value3'].'">'.$row['realName'].'</a>', # Author's Link
),
);
}
// Free the $result from the query's trap :P
mysql_free_result($result);
// Return the array if output method is selected as "array"
if($output_method == 'array')
return $comments;
// If it is Not "array", output the default looks.
$counter = 0;
echo '<span class="normaltext">';
foreach($comments as $c)
{
$counter++;
echo '<div>',$c['link'],'</div>';
// Show the author?
if($show_author)
echo 'Posted By ',$c['author']['link'];
// Show the time its posted at?
if($show_time)
echo '<br />At ',$c['time'];
// Show in which article the comment is posted?
if($show_articleComment)
echo '<br />In ',$c['article']['link'];
if($counter < $limit)
echo '<hr />';
}
}
}
articles(
$mode = 1,
$limit = 5,
$cats = array(60,1,50,167),
$show_comments = false,
$show_views = false,
$show_rating = false,
$show_time = false,
$show_category = false,
$show_author = false,
$show_articleComment = false,
$output_method = 'echo'
);
echo '
</td>
</tr>
</table>';
I know that I am asking too much so take your time with this one or just ignore my request.
Thank you.