e107
Posted by quiznos
You are looking for two functions:
phorum_get_url():
[code="php"]
foreach ($msgs as $msg_id => $data) {
$msgs[$msg_id]["URL"]["READ"] = phorum_get_url(PHORUM_READ_URL, $data['thread'], $data['message_id']);
}
[/code]
This would be accessed in your loop as {ULTIMOS->URL->READ}.
and phorum_date():
[code="php"]
// first pull in the date format you want to use (set in your language file)
// here I pull in the short_date_time, the long_date_time is also an option
// NOTE: this is after your global $PHORUM call.
$date_format = $PHORUM["short_date_time"];
foreach ($msgs as $msg_id => $data) {
$msgs[$msg_id]["formatted_date"] = phorum_date($date_format, $data["datestamp"]);
}
[/code]
Again this can be accessed as {ULTIMOS->formatted_date}. This also has the advantage of adjusting the date to the current user's timezone.
Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Edited 1 time(s). Last edit at 12/07/2008 06:13PM by Joe Curia.
phorum_get_url():
[code="php"]
foreach ($msgs as $msg_id => $data) {
$msgs[$msg_id]["URL"]["READ"] = phorum_get_url(PHORUM_READ_URL, $data['thread'], $data['message_id']);
}
[/code]
This would be accessed in your loop as {ULTIMOS->URL->READ}.
and phorum_date():
[code="php"]
// first pull in the date format you want to use (set in your language file)
// here I pull in the short_date_time, the long_date_time is also an option
// NOTE: this is after your global $PHORUM call.
$date_format = $PHORUM["short_date_time"];
foreach ($msgs as $msg_id => $data) {
$msgs[$msg_id]["formatted_date"] = phorum_date($date_format, $data["datestamp"]);
}
[/code]
Again this can be accessed as {ULTIMOS->formatted_date}. This also has the advantage of adjusting the date to the current user's timezone.
Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Edited 1 time(s). Last edit at 12/07/2008 06:13PM by Joe Curia.
Excellent. Works fine except the date, which returns undefined date (01/01/1970). Any ideas?
Is the phorum_get_url() documented anywhere? I feel sorry about asking so many questions but many times I am unable to find the right information on docs (no complain!)
BTW I noticed too the loop generates an extra empty row. I am doing something wrong?
This is the code I am currently using, and URL where I use it
[code="php"]
<?php
global $PHORUM;
$date_format = $PHORUM["short_date_time"];
$msgs = phorum_db_get_recent_messages(6,0,$PHORUM["DATA"]["FORUM_ID"],0,LIST_RECENT_MESSAGES);
foreach ($msgs as $msg_id => $data) {
$msgs[$msg_id]["URL"]["READ"] = phorum_get_url(PHORUM_READ_URL, $data['thread'], $data['message_id']);}
foreach ($msgs as $msg_id => $data) {
$msgs[$msg_id]["formatted_date"] = phorum_date($date_format, $date["datestamp"]);}
$PHORUM["DATA"]["ULTIMOS"] = $msgs;
?>
<table>
<tr><th>Ultimos mensajes</th></tr>
{LOOP ULTIMOS}
<tr><td><a href="{ULTIMOS->URL->READ}">{ULTIMOS->subject}</a></td>
<td>{ULTIMOS->author}</td><td>{ULTIMOS->formatted_date}</td></tr>
{/LOOP ULTIMOS}
</table>
[/code]
Is the phorum_get_url() documented anywhere? I feel sorry about asking so many questions but many times I am unable to find the right information on docs (no complain!)
BTW I noticed too the loop generates an extra empty row. I am doing something wrong?
This is the code I am currently using, and URL where I use it
[code="php"]
<?php
global $PHORUM;
$date_format = $PHORUM["short_date_time"];
$msgs = phorum_db_get_recent_messages(6,0,$PHORUM["DATA"]["FORUM_ID"],0,LIST_RECENT_MESSAGES);
foreach ($msgs as $msg_id => $data) {
$msgs[$msg_id]["URL"]["READ"] = phorum_get_url(PHORUM_READ_URL, $data['thread'], $data['message_id']);}
foreach ($msgs as $msg_id => $data) {
$msgs[$msg_id]["formatted_date"] = phorum_date($date_format, $date["datestamp"]);}
$PHORUM["DATA"]["ULTIMOS"] = $msgs;
?>
<table>
<tr><th>Ultimos mensajes</th></tr>
{LOOP ULTIMOS}
<tr><td><a href="{ULTIMOS->URL->READ}">{ULTIMOS->subject}</a></td>
<td>{ULTIMOS->author}</td><td>{ULTIMOS->formatted_date}</td></tr>
{/LOOP ULTIMOS}
</table>
[/code]
I'm terribly sorry, my example showed $date["datestamp"] rather than $data["datestamp"].
As for phorum_get_url(), you can read the docs here. Some info is there, but you may want to simply browse the code as well (include/phorum_get_url.php).
Looking at your code, you can also combine your two foreach $msgs loops into one loop.
Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
As for phorum_get_url(), you can read the docs here. Some info is there, but you may want to simply browse the code as well (include/phorum_get_url.php).
Looking at your code, you can also combine your two foreach $msgs loops into one loop.
Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
yeah, I somehow overlooked that too. Probably my brain thought there was nothing wrong in a var called date :)
now works fine (combined those too). Any idea why do I get an extra line when looping?
About docs, I swear that tried to find for that function, but as far as i know there is no search feature on there.
Is this something could be incorporated? I can't see why it is not possible to search on docs! :)
Thanks again for all help
now works fine (combined those too). Any idea why do I get an extra line when looping?
About docs, I swear that tried to find for that function, but as far as i know there is no search feature on there.
Is this something could be incorporated? I can't see why it is not possible to search on docs! :)
Thanks again for all help
It appears that the last row of the $msgs returned by phorum_db_get_recent_messages() is actually an array of users. You should be able to add the following (with lines included for positioning):
[code="php"]
$msgs = phorum_db_get_recent_messages(6,0,$PHORUM["DATA"]["FORUM_ID"],0,LIST_RECENT_MESSAGES);
if (isset($msgs["users"])) unset($msgs["users"]);
foreach ($msgs as $msg_id => $data) {
[/code]
Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
[code="php"]
$msgs = phorum_db_get_recent_messages(6,0,$PHORUM["DATA"]["FORUM_ID"],0,LIST_RECENT_MESSAGES);
if (isset($msgs["users"])) unset($msgs["users"]);
foreach ($msgs as $msg_id => $data) {
[/code]
Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
it worked :)
now it is working exacty as expected in a really clean and easy way.
[u2eastlink.com]
Thanks so much! :)
now it is working exacty as expected in a really clean and easy way.
[u2eastlink.com]
Thanks so much! :)
Quote
Diego
[code="php"]
foreach ($msgs as $msg_id => $data) {
$msgs[$msg_id]["URL"]["READ"] = phorum_get_url(PHORUM_READ_URL, $data['thread'], $data['message_id']);}
foreach ($msgs as $msg_id => $data) {
$msgs[$msg_id]["formatted_date"] = phorum_date($date_format, $date["datestamp"]);}
[/code]
You could/should put the stuff inside one foreach as the loop is exaclty the same.
---
-=[ Panu ]=-
Quote
Diego
About docs, I swear that tried to find for that function, but as far as i know there is no search feature on there.
Is this something could be incorporated? I can't see why it is not possible to search on docs! :)
This has been sitting in the back of my head for a while. Google is my "quick and easy" answer for this. Try a search on "site:www.phorum.org/docs your search terms" (ie. [www.google.com]).
If the Phorum devs like this, they might place a Google search form on the documentation pages with the site variable prefilled. *wink wink*
Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Sorry, only registered users may post in this forum.
