"First Events Shown" Tutorial

smartmusic posted 14th of August 2009 in Community Voice. 3 comments.

Many User ask me how to set the sorting from events, here is small tutorial

Modification for 6.1.x.

If you want, that the next events from the future are shown first at home page block, account, profile and events.php



..:: Modification for ALL EVENTS (events.php) ::..

edit the file "inc/classes/BxDolEvents.php"

1. in function PageSDatingShowEvents

find the code (~466 line)

$sOrderBySQL = "ORDER BY `SDatingEvents`.`EventStart` DESC";

and replace it with

$sOrderBySQL = "ORDER BY `SDatingEvents`.`EventStart` ASC";


..:: Modification for EVENT BLOCK at homepage, your account and profile ::..

1. edit the file "inc/classes/BxDolEvents.php" in function GenAnyBlockContent

find the code (~2240 line)

$sOrderS = '';
switch ($sOrder) {
case 'last':
case 'latest':
$sOrderS = "ORDER BY `EventStart` DESC";
break;
case 'rand':
$sOrderS = "ORDER BY RAND()";
break;
case 'first':
$sOrderS = "ORDER BY `EventStart` ASC";
break;
}

and replace with

$sOrderS = '';
switch ($sOrder) {
case 'latest':
$sOrderS = "ORDER BY `EventStart` DESC";
break;
case 'rand':
$sOrderS = "ORDER BY RAND()";
break;
case 'last':
case 'first':
$sOrderS = "ORDER BY `EventStart` ASC";
break;
}

2. edit the file "templates/base/BxBaseIndex.php" in function getBlockCode_Events

find the code (~976 line)

$mode = $_REQUEST['events_mode'];
if( $mode != 'rand' and $mode != 'latest' )
$mode = 'latest';

$aDBTopMenu = array();
foreach( array( 'latest', 'rand' ) as $myMode ) {
switch( $myMode ) {
case 'latest':
$sTabTitle  = _t( '_Latest' );
break;
case 'rand':
$sTabTitle  = _t( '_Random' );
break;
}

and replace with

$mode = $_REQUEST['events_mode'];
if( $mode != 'first' and $mode != 'rand' and $mode != 'latest' )
$mode = 'first';

$aDBTopMenu = array();
foreach( array( 'first','latest', 'rand' ) as $myMode ) {
switch( $myMode ) {
case 'first':
$sTabTitle  = _t( '_First' );
break;
case 'latest':
$sTabTitle  = _t( '_Latest' );
break;
case 'rand':
$sTabTitle  = _t( '_Random' );
break;
}

Demo: http://www.ue30-party.com/events?lang=en

 
Comments
·Oldest
·Top
Please login to post a comment.
DeeEmm
Doesn't work if you add advance events (ie next years events) - it will simply show these events in preference, and not the upcoming events between now and then.

To fix this - use the following SQL

$sOrderS = "AND `EventStart` BETWEEN NOW() AND NOW()+ INTERVAL 362 DAY ORDER BY `EventStart` ASC";

There's full instructions on my site...

http://www.deeemm.com/index.php?page=how%20to&id=13

My mod is a little dirtier and could do with smartmusics addition of the additional see more tabs to make it better.
DeeEmm
Sorry perhaps I should explain a little better - SQL in my post will show the events from today forwards - ie next occurring event in time + event after + event after that.

DM
this modification from me works like it is,
the blog is, that first events are shown, doesn´t matter if the first events are past or future...

so you have two choices that only future first events are shown:

1. you delete past events

2.

..:: Modification for your HOME Page event block ::..

1. edit the file "templates/base/scripts/BxBaseIndex.php"

Find code (~1192 line)

$iTotalNum = db_value("SELECT COUNT(*) AS 'Cnt' FROM `SDatingEvents` WHERE `Status` = 'Active'");

and see more replace it with

$iTotalNum = db_value("SELECT COUNT(*) AS 'Cnt' FROM `SDatingEvents` WHERE `Status` = 'Active' AND `EventEnd` >= NOW()");



2. edit the file "inc/classes/BxDolEvents.php"

Find code (~2294 line) in function GenAnyBlockContent

AND `SDatingEvents`.`Status` = 'Active'

and replace it with

AND `SDatingEvents`.`Status` = 'Active' AND `SDatingEvents`.`EventEnd` >= NOW()




..:: Modification for "All Events", "My Events" and "Search Events" ::..


1. edit the file "inc/classes/BxDolEvents.php"

find code (~462 line) in function PageSDatingShowEvents

$sStatusActiveSQL = "`SDatingEvents`.`Status` = 'Active'";

and replace it with

$sStatusActiveSQL = "`SDatingEvents`.`Status` = 'Active' AND `SDatingEvents`.`EventEnd` >= NOW()";



---------------------------------------------------

If you don´t want to set all the time the end time from each event you can change everywhere the part

AND `SDatingEvents`.`EventEnd` >= NOW()

to

AND `SDatingEvents`.`EventStart` +24000 >= NOW()


now all events 1 day after eventstart are not shown anymore

you can set yourself the time

24000 = 24 hours

1000 = 1 Hour
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.
PET:0.064953088760376