Welcome to Geeklog, Anonymous Thursday, April 17 2025 @ 06:21 pm EDT
Geeklog Forums
Journal Block
Status: offline
Dazzy
Forum User
Full Member
Registered: 07/19/03
Posts: 200
Location:N. Ireland
Hi
Does anyone know how to limit the number of Journals displayed in this block for say the last 10 days?
Currently it diesplays all jouurnals and is getting on the large size!
function phpblock_journal2 ()
{
global $_CONF, $_TABLES, $LANG_JOURNAL;
$retval = '';
$sql = "SELECT jrn_id,jrn_uid,jrn_name FROM {$_TABLES['journal']} WHERE jrn_public = 1 ORDER BY jrn_name";
$result = DB_query ($sql);
$journals = DB_numRows ($result);
if ($journals > 0) {
$retval .= '<table border="0" width="100%">' . LB;
for ($j = 1; $j <= $journals; $j++) {
$J = DB_fetchArray ($result);
$username = DB_getItem ($_TABLES['users'], 'username', "uid = {$J['jrn_uid']}");
$sql = "SELECT je_summary,je_mood,UNIX_TIMESTAMP(je_date) AS date FROM {$_TABLES['journal_entry']} WHERE (je_jrn_id = {$J['jrn_id']}) AND (je_public = 1) ORDER BY je_date DESC LIMIT 1";
$eresult = DB_query ($sql);
$entries = DB_numRows ($eresult);
if ($entries == 0) {
$retval .= '<tr><td> </td>';
$retval .= '<td><a href="' . $_CONF['site_url']
. '/journal/index.php?mode=user&jrn_id='
. $J['jrn_id'] . '">' . stripslashes ($J['jrn_name'])
. '</a> (' . $username . ')<br><em>'
. $LANG_JOURNAL['block_no_entries'] . '</em></td></tr>'
. LB;
} else {
$A = DB_fetchArray ($eresult);
$mood = $A['je_mood'];
if (empty ($mood)) {
$retval .= '<tr><td> </td>';
} else {
$retval .= '<tr><td valign="top"><img src="'
. $_CONF['site_url'] . '/journal/images/' . $mood
. '_phpbb.gif' . '" alt="[' . $LANG_JOURNAL['mood_' . $mood] . ']" title="' . $LANG_JOURNAL['mood_' . $mood] . '"></td>';
}
$retval .= '<td><a href="' . $_CONF['site_url']
. '/journal/index.php?mode=user&jrn_id='
. $J['jrn_id'] . '">' . stripslashes ($J['jrn_name'])
. '</a> (' . $username . ')<br>'
. '<strong>' . stripslashes ($A['je_summary'])
. '</strong><br>'
. '<em>' . strftime ($_CONF['shortdate'], $A['date'])
. '</em></td></tr>' . LB;
}
}
$retval .= '</table>' . LB;
} else {
$retval .= '<em>' . $LANG_JOURNAL['block_no_journals'] . '</em>';
}
return $retval;
}
Thanks
Dazzy
Does anyone know how to limit the number of Journals displayed in this block for say the last 10 days?
Currently it diesplays all jouurnals and is getting on the large size!
Text Formatted Code
function phpblock_journal2 ()
{
global $_CONF, $_TABLES, $LANG_JOURNAL;
$retval = '';
$sql = "SELECT jrn_id,jrn_uid,jrn_name FROM {$_TABLES['journal']} WHERE jrn_public = 1 ORDER BY jrn_name";
$result = DB_query ($sql);
$journals = DB_numRows ($result);
if ($journals > 0) {
$retval .= '<table border="0" width="100%">' . LB;
for ($j = 1; $j <= $journals; $j++) {
$J = DB_fetchArray ($result);
$username = DB_getItem ($_TABLES['users'], 'username', "uid = {$J['jrn_uid']}");
$sql = "SELECT je_summary,je_mood,UNIX_TIMESTAMP(je_date) AS date FROM {$_TABLES['journal_entry']} WHERE (je_jrn_id = {$J['jrn_id']}) AND (je_public = 1) ORDER BY je_date DESC LIMIT 1";
$eresult = DB_query ($sql);
$entries = DB_numRows ($eresult);
if ($entries == 0) {
$retval .= '<tr><td> </td>';
$retval .= '<td><a href="' . $_CONF['site_url']
. '/journal/index.php?mode=user&jrn_id='
. $J['jrn_id'] . '">' . stripslashes ($J['jrn_name'])
. '</a> (' . $username . ')<br><em>'
. $LANG_JOURNAL['block_no_entries'] . '</em></td></tr>'
. LB;
} else {
$A = DB_fetchArray ($eresult);
$mood = $A['je_mood'];
if (empty ($mood)) {
$retval .= '<tr><td> </td>';
} else {
$retval .= '<tr><td valign="top"><img src="'
. $_CONF['site_url'] . '/journal/images/' . $mood
. '_phpbb.gif' . '" alt="[' . $LANG_JOURNAL['mood_' . $mood] . ']" title="' . $LANG_JOURNAL['mood_' . $mood] . '"></td>';
}
$retval .= '<td><a href="' . $_CONF['site_url']
. '/journal/index.php?mode=user&jrn_id='
. $J['jrn_id'] . '">' . stripslashes ($J['jrn_name'])
. '</a> (' . $username . ')<br>'
. '<strong>' . stripslashes ($A['je_summary'])
. '</strong><br>'
. '<em>' . strftime ($_CONF['shortdate'], $A['date'])
. '</em></td></tr>' . LB;
}
}
$retval .= '</table>' . LB;
} else {
$retval .= '<em>' . $LANG_JOURNAL['block_no_journals'] . '</em>';
}
return $retval;
}
Thanks
Dazzy
9
12
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by Dazzy: Does anyone know how to limit the number of Journals displayed in this block for say the last 10 days?
The block was written to display the last post for each journal. What you want would effectively require a rewrite of the block.
Neither impossible nor to hard for someone with a bit of PHP and MySQL knowledge, though ...
bye, Dirk
10
11
Quote
All times are EDT. The time is now 06:21 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content