Welcome to Geeklog, Anonymous Friday, November 08 2024 @ 08:56 pm EST
Geeklog Forums
Calendar next events on front page
Status: offline
::Ben
Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Hello,
In lib-custom.php add this function:
function phpblock_listevents( $displaymode='display' )
{
global $_TABLES, $LANG01, $LANG02, $LANG22, $_CONF, $LANG_ACCESS;
$retval = '';
$event_templates = new Template($_CONF['path_system'] . 'custom/event');
$event_templates->set_file(array('list'=>'eventlist.thtml','row'=>'listitem.thtml'));
$event_templates->set_var('site_url', $_CONF['site_url']);
$result = DB_query("SELECT * FROM {$_TABLES['events']} WHERE TO_DAYS(dateend) >= TO_DAYS(NOW()) ORDER BY datestart, timestart");
$nrows = DB_numRows($result);
if ($nrows > 0) {
for ($i = 0;$i < $nrows; $i++) {
$A = DB_fetchArray($result);
$access = SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']);
if ($access > 0) {
$thesdatetime = strftime( '%A %d %B %Y', strtotime($A['datestart'].' '.$A['timestart']) );
$event_templates->set_var('event_id', $A['eid']);
$event_templates->set_var('event_title', $A['title']);
$event_templates->set_var('event_access', $access);
$theedatetime = strftime( '%A %d %B %Y', strtotime($A['dateend'].' '.$A['timeend']) );
if( $A['datestart'] == $A['dateend'] )
{$event_templates->set_var('event_cal', $thesdatetime);}
else
{$event_templates->set_var('event_cal', $thesdatetime);}
$event_templates->parse('event_row', 'row', true);
}
}
$event_templates->parse('output', 'list');
} else if ($nrows < 1) {
$retval .= "No next event.";
}
$retval .= $event_templates->finish($event_templates->get_var('output'));
return $retval;
}
Create a custom folder in the system folder. Create a event folder in the custom folder and add these two files:
eventlist.thtml
<!-- eventlist.thtml -->
<table border="0" cellspacing="0" cellpadding=3 width="100%">
<tr>
<th align="left">Calendar</th>
<th width="60%" align="left"></th>
</tr>
{event_row}
</table>
<p><br/>You can <a href="{site_url}/submit.php?type=calendar">add an event</a> in this calendar or <a href="{site_url}/calendar/index.php">see the calendar</a>.</p>
listitem.thtml
<!-- listitem.thtml -->
<tr align="center">
<td align="left" valign="top" style="border-bottom:1px solid #EEE; padding-left:5px;">{event_cal}</td>
<td align="left" valign="top" style="border-bottom:1px solid #EEE;padding-left:5px;">
<a href="{site_url}/calendar/event.php?eid={event_id}">{event_title}</a>
</td>
</tr>
Then in a php static page center block on front page:
echo phpblock_listevents(display);
::Ben
I'm available to customise your themes or plugins for your Geeklog CMS
In lib-custom.php add this function:
Text Formatted Code
function phpblock_listevents( $displaymode='display' )
{
global $_TABLES, $LANG01, $LANG02, $LANG22, $_CONF, $LANG_ACCESS;
$retval = '';
$event_templates = new Template($_CONF['path_system'] . 'custom/event');
$event_templates->set_file(array('list'=>'eventlist.thtml','row'=>'listitem.thtml'));
$event_templates->set_var('site_url', $_CONF['site_url']);
$result = DB_query("SELECT * FROM {$_TABLES['events']} WHERE TO_DAYS(dateend) >= TO_DAYS(NOW()) ORDER BY datestart, timestart");
$nrows = DB_numRows($result);
if ($nrows > 0) {
for ($i = 0;$i < $nrows; $i++) {
$A = DB_fetchArray($result);
$access = SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']);
if ($access > 0) {
$thesdatetime = strftime( '%A %d %B %Y', strtotime($A['datestart'].' '.$A['timestart']) );
$event_templates->set_var('event_id', $A['eid']);
$event_templates->set_var('event_title', $A['title']);
$event_templates->set_var('event_access', $access);
$theedatetime = strftime( '%A %d %B %Y', strtotime($A['dateend'].' '.$A['timeend']) );
if( $A['datestart'] == $A['dateend'] )
{$event_templates->set_var('event_cal', $thesdatetime);}
else
{$event_templates->set_var('event_cal', $thesdatetime);}
$event_templates->parse('event_row', 'row', true);
}
}
$event_templates->parse('output', 'list');
} else if ($nrows < 1) {
$retval .= "No next event.";
}
$retval .= $event_templates->finish($event_templates->get_var('output'));
return $retval;
}
Create a custom folder in the system folder. Create a event folder in the custom folder and add these two files:
eventlist.thtml
Text Formatted Code
<!-- eventlist.thtml -->
<table border="0" cellspacing="0" cellpadding=3 width="100%">
<tr>
<th align="left">Calendar</th>
<th width="60%" align="left"></th>
</tr>
{event_row}
</table>
<p><br/>You can <a href="{site_url}/submit.php?type=calendar">add an event</a> in this calendar or <a href="{site_url}/calendar/index.php">see the calendar</a>.</p>
listitem.thtml
Text Formatted Code
<!-- listitem.thtml -->
<tr align="center">
<td align="left" valign="top" style="border-bottom:1px solid #EEE; padding-left:5px;">{event_cal}</td>
<td align="left" valign="top" style="border-bottom:1px solid #EEE;padding-left:5px;">
<a href="{site_url}/calendar/event.php?eid={event_id}">{event_title}</a>
</td>
</tr>
Then in a php static page center block on front page:
Text Formatted Code
echo phpblock_listevents(display);
::Ben
I'm available to customise your themes or plugins for your Geeklog CMS
17
19
Quote
All times are EST. The time is now 08:56 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