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

Recent

Welcome to TinyPortal. Please login or sign up.

May 02, 2024, 08:54:16 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,178
  • Total Topics: 21,220
  • Online today: 151
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 93
  • Total: 94
  • @rjen

Help with Block code update

Started by fangweile, January 17, 2012, 03:47:02 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fangweile

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.

IchBin

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';
}

fangweile

THanks a lot IchBin, it works great.