Welcome to Geeklog Tuesday, October 17 2017 @ 03:47 am EDT


Status: offline

::Ben

Forum User
Full Member
Registered: 14/01/2005
Posts: 1569
Location:la rochelle, France
Hello,

In lib-custom.php add this function:

PHP 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

PHP 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
PHP 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:

PHP Formatted Code

echo phpblock_listevents(display);
 


::Ben
I'm available to customise your themes or plugins for your Geeklog CMS

All times are EDT. The time is now 03:47 am.

  • 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