I used the following blockscodes below in older version of tinyportal and using smf 1.1.4 and when i upgrade to the latest version TPRC3 and SMF 2, it doesnt work anymore.
The code below shows article intro in a block by most viewed.
global $db_prefix, $scripturl;
$query = db_query(
"SELECT intro
FROM {$db_prefix}tp_articles
WHERE useintro = 1
AND category=4
ORDER BY views DESC
LIMIT 1", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
echo htmlspecialchars_decode($row['intro']);
Another is a block showing articles in creation date.
global $db_prefix, $scripturl;
$today = date('-m-d', strtotime("+13 hours"));
$query = db_query(
"SELECT intro, id, date, subject, shortname
FROM {$db_prefix}tp_articles
WHERE FROM_UNIXTIME(date) LIKE '%" . $today . "%'
AND category=1
AND approved=1", __FILE__, __LINE__);
if(db_affected_rows() != 0)
{
echo date ("l, F d, Y h:i:s a", strtotime("+13 hours"));
echo '<br />';
while ($row = mysql_fetch_assoc($query))
{
echo htmlspecialchars_decode($row['intro']);
}
}
else {
echo date ("l, F d, Y h:i:s a", strtotime("+13 hours"));
echo '<br />';
echo 'No Birthdays Found in Database';
}
I think that the block codes above is need to be updated to work with TP1
THanks in advance.
This should work.
global $smcFunc, $scripturl;
$query = $smcFunc['db_query']('', '
SELECT intro
FROM {db_prefix}tp_articles
WHERE useintro = {int:intro}
AND category = {int:cat}
ORDER BY views DESC
LIMIT 1',
array('intro' => 1, 'cat' => 4)
);
while ($row = $smcFunc['db_fetch_assoc']($query))
echo htmlspecialchars_decode($row['intro']);
global $smcFunc, $scripturl;
$today = date('-m-d', strtotime("+13 hours"));
$query = $smcFunc['db_query']('', '
SELECT intro, id, date, subject, shortname
FROM {db_prefix}tp_articles
WHERE FROM_UNIXTIME(date) LIKE "%' . $today . '%"
AND category = {int:cat}
AND approved = {int:approved}',
array('cat' => 1, 'approved' => 1)
);
if($smcFunc['db_affected_rows']() != 0)
{
echo date ("l, F d, Y h:i:s a", strtotime("+13 hours"));
echo '<br />';
while ($row = $smcFunc['db_fetch_assoc']($query))
{
echo htmlspecialchars_decode($row['intro']);
}
}
else
{
echo date ("l, F d, Y h:i:s a", strtotime("+13 hours"));
echo '<br /> No Birthdays Found in Database';
}
THanks a lot IchBin, it works great.