Author Topic: Procalendar droplet to show all but first 3 events?  (Read 3857 times)

Offline Roych

  • Betatester
  • **
  • Posts: 573
  • Gender: Male
Procalendar droplet to show all but first 3 events?
« on: April 17, 2016, 03:09:55 PM »
Hello,


I have a question if it is possible to show all events (or some number) of events but without the first three. As I would show first three events larger with images (already done that) and other events only as list below.
I have all working already I only need to call the droplet without first three events.


Right now I have:
Code: [Select]
[[Events-list?section_id=8&dateend=2080-07-13&max=10]]

Can this be done?


And another question. I have a time counter for the upcoming event and need to bring only the date and hour from the first upcoming event like this:
April 18, 2016, 15:30
How to achieve this?




Thank you very much
R

Offline marmot

  • Posts: 1103
Re: Procalendar droplet to show all but first 3 events?
« Reply #1 on: April 17, 2016, 08:23:13 PM »
Hi,
Can this be done?
Surely, the events are processed in a loop. Just use a counter to jump over the processing for the first events. There are a lot of verions of this droplet out there and most of them are even custom patched. So if you want a more detailed answer you can post your droplet here.
Quote
I have a time counter for the upcoming event and need to bring only the date and hour from the first upcoming event
Same answer, just use a counter to identify the first event.

regards

Offline Roych

  • Betatester
  • **
  • Posts: 573
  • Gender: Male
Re: Procalendar droplet to show all but first 3 events?
« Reply #2 on: April 17, 2016, 09:35:45 PM »
Hi,
Can this be done?
Surely, the events are processed in a loop. Just use a counter to jump over the processing for the first events. There are a lot of verions of this droplet out there and most of them are even custom patched. So if you want a more detailed answer you can post your droplet here.
Quote
I have a time counter for the upcoming event and need to bring only the date and hour from the first upcoming event
Same answer, just use a counter to identify the first event.

regards


Thank you for answer. I got the Second (counter) question already working, so I only need the first one.


I'm posting my droplet here:
Code: [Select]



// if (PAGE_ID != 3) {






//:Show next #N events
//:
// Get_Concerts
global $database, $wb;


setlocale (LC_ALL, 'sl_SI.UTF-8'); //za vse kategorije
setlocale (LC_TIME, 'sl_SI.UTF-8'); //za datumske funkcije


// Show how many items, defaults to 10?
if ( !isset($max) ){ $max = 10; };


// year and month and section defaults
if(!isset($year)) {$year = date('Y', time()); }
if(!isset($month)) {$month = date('n', time()); }
if(!isset($section_id)) {$section_id = 0 ; }




// Set dateformat to suit your needs, add timeformat if needed
$dateformat = 'd'; // Standard php date formats
$datemonth = 'M'; // Standard php date formats
$dateyear = 'Y'; // Standard php date formats


// Fetch base page link, if event_id = set
$extrasql = '';
$page_id = 0;
$page_link ='';


if ($section_id<>0) {
$extrasql = " section_id = '".$section_id."' AND ";
$sql = "SELECT page_id FROM ".TABLE_PREFIX."sections WHERE section_id = '".$section_id."'";
$result = $database->query($sql);
if ( $result->numRows() > 0 ) {
while( $row = $result->fetchRow() ) {
$page_id = $row['page_id'];
}
}
if ($page_id <> 0) {
$sql = "SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".$page_id."'";
$result = $database->query($sql);
if ( $result->numRows() > 0 ) {
while( $row = $result->fetchRow() ) {
$page_link = page_link($row['link']);
}
}
}
}




// Set start- and end date for query
// $datestart = "$year-$month-1"; ORIGINAL = show all events in this month
$datestart = date("Y-m-d"); // ALTERNATIVE = show all events in this month, starting today
$dateend = "$year-$month-".cal_days_in_month(CAL_GREGORIAN, $month,$year);


// Fetch the items
$sql = "SELECT DAY(date_start) AS day, id, custom1, date_start, time_start, date_end, time_end, name FROM ".TABLE_PREFIX."mod_procalendar_actions WHERE ".$extrasql." date_start >='$datestart' AND public_stat = 0 ORDER BY date_start,time_start LIMIT 0, ".$max." ";
$mod_query = $database->query($sql);
while ( $row =& $mod_query->fetchRow()){
// Build url like : pages/kalendar.php?id=2&detail=1
$page_url = $page_link.'?id='.$row['id'].'&amp;detail=1';
$ds = $row['date_start']." ".substr($row['time_start'],0,5);
$de = $row['date_end']." ".substr($row['time_end'],0,5);
$datetime_start = mktime(substr($ds,11,2),substr($ds,14,2),0,substr($ds,5,2),substr($ds,8,2),substr($ds,0,4));
$datetime_end = mktime(substr($de,11,2),substr($de,14,2),0,substr($de,5,2),substr($de,8,2),substr($de,0,4));
 
    $printTime = $row['time_start'];





$mod_list.= '
 
                              <ul>
                  <li class="item event-item">
               
                 
                    <div class="event-date">
                    <span class="date">'.date($dateformat,$datetime_start).'</span>
                    <span class="month">'.date($datemonth,$datetime_start).'</span>
                    <span class="leto">'.date($dateyear,$datetime_start).'</span>
                    <>';
                   
       


             


                     
if(date('Y-m-d',$datetime_start)==date('Y-m-d')){                   
  $mod_list.= '<div class="event-detail">
                      <h4><a href="'.$page_url.'">'.$row["name"].'</a></h4>
<span class="event-dayntime meta-data">
                         Začetek ob: '.substr($printTime,0,5).' uri. |
  <span class="danes" style="color:red"> Today!</span>
</span><>

                    <div class="to-event-url">
                      <div><a href="'.$page_url.'" class="btn btn-default btn-sm">Podrobnosti</a><>
                    <>
                 </li></ul>
              ';
  }
 
else{
$mod_list.= '<div class="event-detail">
                      <h4><a href="'.$page_url.'">'.$row["name"].'</a></h4>
<span class="event-dayntime meta-data">
Začetek ob: '.substr($printTime,0,5).' uri.
</span> <>

                    <div class="to-event-url">
                      <div><a href="'.$page_url.'" class="btn btn-default btn-sm">Podrobnosti</a><>
                    <>
                 
               
                      </li></ul>         ';
  }
                 
         
}
 return $mod_list;


// }


So I need to hide the first three events and show all others.
Hope this helps


Thank you very much


R

Offline Ruud

  • Posts: 3660
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Procalendar droplet to show all but first 3 events?
« Reply #3 on: April 17, 2016, 10:57:47 PM »
You can change the sql query to get number 4 to 14 (if $max=10)

Change this line
Code: [Select]
$sql = "SELECT DAY(date_start) AS day, id, custom1, date_start, time_start, date_end, time_end, name FROM ".TABLE_PREFIX."mod_procalendar_actions WHERE ".$extrasql." date_start >='$datestart' AND public_stat = 0 ORDER BY date_start,time_start LIMIT 0, ".$max." ";
into
Code: [Select]
$sql = "SELECT DAY(date_start) AS day, id, custom1, date_start, time_start, date_end, time_end, name FROM ".TABLE_PREFIX."mod_procalendar_actions WHERE ".$extrasql." date_start >='$datestart' AND public_stat = 0 ORDER BY date_start,time_start LIMIT 3, ".$max." ";
note the end of the line: "... LIMIT 3, ...."


Offline Roych

  • Betatester
  • **
  • Posts: 573
  • Gender: Male
Re: Procalendar droplet to show all but first 3 events?
« Reply #4 on: April 17, 2016, 11:42:13 PM »
You can change the sql query to get number 4 to 14 (if $max=10)

Change this line
Code: [Select]
$sql = "SELECT DAY(date_start) AS day, id, custom1, date_start, time_start, date_end, time_end, name FROM ".TABLE_PREFIX."mod_procalendar_act ions WHERE ".$extrasql." date_start >='$datestart' AND public_stat = 0 ORDER BY date_start,time_start LIMIT 0, ".$max." ";
into
Code: [Select]
$sql = "SELECT DAY(date_start) AS day, id, custom1, date_start, time_start, date_end, time_end, name FROM ".TABLE_PREFIX."mod_procalendar_act ions WHERE ".$extrasql." date_start >='$datestart' AND public_stat = 0 ORDER BY date_start,time_start LIMIT 3, ".$max." ";
note the end of the line: "... LIMIT 3, ...."


Works perfect, thank you. ;)


One more thing I noticed and it looks a little weird. I would like the event to dissapear after it is finnished expl. on end-hour. because if I have two events on the same day the counter stops at first event and stays till the next day before the event is gone from the list and the counter starts counting from the next event.
I would like counter to immediately go to the next event.


This is my counter droplet.
Code: [Select]

// if (PAGE_ID != 3) {






//:Show next #N events
//:
// Get_Concerts
global $database, $wb;


setlocale (LC_ALL, 'sl_SI.UTF-8'); //za vse kategorije
setlocale (LC_TIME, 'sl_SI.UTF-8'); //za datumske funkcije


// Show how many items, defaults to 10?
if ( !isset($max) ){ $max = 10; };


// year and month and section defaults
if(!isset($year)) {$year = date('Y', time()); }
if(!isset($month)) {$month = date('m', time()); }
if(!isset($section_id)) {$section_id = 0 ; }




// Set dateformat to suit your needs, add timeformat if needed
$dateformat = 'd'; // Standard php date formats
$datemonth = 'M'; // Standard php date formats
$dateyear = 'Y'; // Standard php date formats


// Fetch base page link, if event_id = set
$extrasql = '';
$page_id = 0;
$page_link ='';


if ($section_id<>0) {
$extrasql = " section_id = '".$section_id."' AND ";
$sql = "SELECT page_id FROM ".TABLE_PREFIX."sections WHERE section_id = '".$section_id."'";
$result = $database->query($sql);
if ( $result->numRows() > 0 ) {
while( $row = $result->fetchRow() ) {
$page_id = $row['page_id'];
}
}
if ($page_id <> 0) {
$sql = "SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".$page_id."'";
$result = $database->query($sql);
if ( $result->numRows() > 0 ) {
while( $row = $result->fetchRow() ) {
$page_link = page_link($row['link']);
}
}
}
}




// Set start- and end date for query
// $datestart = "$year-$month-1"; ORIGINAL = show all events in this month
$datestart = date("Y-m-d"); // ALTERNATIVE = show all events in this month, starting today
$dateend = "$year-$month-".cal_days_in_month(CAL_GREGORIAN, $month,$year);


// Fetch the items
$sql = "SELECT DAY(date_start) AS day, id, custom1, date_start, time_start, date_end, time_end, name FROM ".TABLE_PREFIX."mod_procalendar_actions WHERE ".$extrasql." date_start >='$datestart' AND public_stat = 0 ORDER BY date_start,time_start LIMIT 0, ".$max." ";
$mod_query = $database->query($sql);
while ( $row =& $mod_query->fetchRow()){
// Build url like : pages/kalendar.php?id=2&detail=1
$page_url = $page_link.'?id='.$row['id'].'&amp;detail=1';
$ds = $row['date_start']." ".substr($row['time_start'],0,5);
$de = $row['date_end']." ".substr($row['time_end'],0,5);
$datetime_start = mktime(substr($ds,11,2),substr($ds,14,2),0,substr($ds,5,2),substr($ds,8,2),substr($ds,0,4));
$datetime_end = mktime(substr($de,11,2),substr($de,14,2),0,substr($de,5,2),substr($de,8,2),substr($de,0,4));
 
    $printTime = $row['time_start'];

$mod_list.= '
 
 
  <div class="notice-bar">
    <div class="container">
      <div class="row">
        <div class="col-md-3 col-sm-6 col-xs-6 notice-bar-title"> <span class="notice-bar-title-icon hidden-xs"><i class="fa fa-calendar fa-3x"></i></span> <span class="title-note">Next</span> <strong>Upcoming event</strong> <>
        <div class="col-md-3 col-sm-6 col-xs-6 notice-bar-event-title">
          <h5><a href="single-event.html">'.$row["name"].'</a></h5>
          <span class="meta-data">'.date($dateformat,$datetime_start).' '.date($datemonth,$datetime_start).', '.date($dateyear,$datetime_start).'</span> <>
        <div id="counter" class="col-md-4 col-sm-6 col-xs-12 counter" data-date="'.date($datemonth,$datetime_start).' '.date($dateformat,$datetime_start).', '.date($dateyear,$datetime_start).', '.substr($printTime,0,5).'">
          <div class="timer-col"> <span id="days"></span> <span class="timer-type">days</span> <>
          <div class="timer-col"> <span id="hours"></span> <span class="timer-type">hrs</span> <>
          <div class="timer-col"> <span id="minutes"></span> <span class="timer-type">mins</span> <>
          <div class="timer-col"> <span id="seconds"></span> <span class="timer-type">secs</span> <>
        <>
        <div class="col-md-2 col-sm-6 hidden-xs"> <a href="events.html" class="btn btn-primary btn-lg btn-block">All Events</a> <>
      <>
    <>
  <>';


}
 return $mod_list;


// }




Is this posible?


Thank you
R

 

postern-length