WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: Olli on June 09, 2007, 01:24:04 PM

Title: display todays events from event-calender on frontpage
Post by: Olli on June 09, 2007, 01:24:04 PM
hello everybody,
this morning i tried to get a code snippet (based on the "display-news-anywhere-snippet") working to display todays events from the eventcalender module on the frontpage...

unfortunately i did not succeed  :-(

has anyone of you ever adapted this snippet to the eventcalender and might help me out?
maybe it's the weathers fault... it's too hot to concentrate on this for proper results ;-)

bye
Title: Re: display todays events from event-calender on frontpage
Post by: kweitzel on June 09, 2007, 04:09:31 PM
Why don't you post your code and we can see what is going wrong ...

cheers

Klaus
Title: Re: display todays events from event-calender on frontpage
Post by: Olli on June 09, 2007, 08:09:02 PM
hi klaus,
i deleted it because of the time i wasted. and it wasn't working so nothing is lost... ;-)
but i will start over and post it here then. hopefully it will work then at once.

bye
Title: Re: display todays events from event-calender on frontpage
Post by: kweitzel on June 09, 2007, 08:22:34 PM
OK ... have a close look at the database tables where you pull the data from ... I think, that is the main difference to the news script.

cheers

Klaus
Title: Re: display todays events from event-calender on frontpage
Post by: Olli on June 09, 2007, 09:31:12 PM
yeah ok i will, thanks dude :-)

bye
Title: Re: display todays events from event-calender on frontpage
Post by: doc on June 10, 2007, 06:25:14 PM
Hello,

you need to add one more query statement to the display news anywhere snippet to achieve what you want. Replace the code lines in the include.php file with the code posted below (without <?php and ?>).

Code: [Select]
<?php
// query to obtain news items for the selected group
$post_intervall time() - (24 3600);  // allow post from now - 1 day * 24h * 60m * 60s
if ($group_id 1) {
  
$query "SELECT * FROM " .TABLE_PREFIX ."mod_news_posts WHERE active=1 AND (posted_when > $post_intervall) ORDER BY position DESC LIMIT 0, $max_news_items;";
} else {
  
$query "SELECT * FROM " .TABLE_PREFIX ."mod_news_posts WHERE group_id=$group_id AND active=1 AND (posted_when > $post_intervall) ORDER BY position DESC LIMIT 0, $max_news_items;";
}
?>


Regards Christian
Title: Re: display todays events from event-calender on frontpage
Post by: kweitzel on June 10, 2007, 07:41:40 PM
Hi Christian,

I think ou misunderstood ... (or did I?) He wants to pull the Data from the Eventcalendar and not "today's latest posts" from the newsmodule ...

But like said, I might be wrong!?!?

cheers

Klaus
Title: Re: display todays events from event-calender on frontpage
Post by: doc on June 10, 2007, 07:48:55 PM
Hello Klaus,

seems you are right. However, maybe this kind of information is usefull for others too  :-)
In general a similar statement is requirement in the calendar script as well to achieve this.

Regards Christian

Title: Re: display todays events from event-calender on frontpage
Post by: Olli on June 10, 2007, 08:02:03 PM
hey guys,
yes i want to display todays events from the eventcalender anywhere else using a code section.
here is what i did. i adapted some code provided by pc-wacht (THANKS DUDE) some months ago.


to make it look better i put everything inside an upscrolling div-container. just delete the two leading <div>-tags from the code-area if you don't like it.


1.put this into your <head>....</head> area for the upscroll:
Code: [Select]
<script type="text/javascript">

var delayb4scroll=2000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?


var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
else
cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}

function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
cross_marquee.style.top=0
marqueeheight=document.getElementById("marqueecontainer").offsetHeight
actualheight=cross_marquee.offsetHeight
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
cross_marquee.style.height=marqueeheight+"px"
cross_marquee.style.overflow="scroll"
return
}
setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
}

if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
window.onload=initializemarquee
</script>


2.this is for your css-file (only needed if you want to use the upscrolling effect)

Code: [Select]
#marqueecontainer{
text-align: left;
height: 180px;
width: 150px;
position: relative;
background-color: #E94747;
/* d31515 */
overflow: hidden;
border: 1px solid Maroon;
padding: 2px;
}


3. this is for the code-area
Code: [Select]
echo "Heutiger Auszug aus dem Veranstaltungskalender<br>";
echo "<div id=\"marqueecontainer\" onMouseover=\"copyspeed=pausespeed\" onMouseout=\"copyspeed=marqueespeed\"><div id=\"vmarquee\" style=\"position: relative; width: 98%;\">";



$datum = date("Y-m-d");
$get_page = 2; // change to your page_id you need
global $database;
$query = "SELECT * FROM `".TABLE_PREFIX."mod_event_dates` WHERE page_id = '$get_page' && date = '$datum' ORDER BY date DESC LIMIT 0, 5;";

$error = mysql_error();
if (!$result = mysql_query($query)) {
print "$error";
exit;
}




while($data = mysql_fetch_object($result)){

$eventsgefunden=1;
$page_id = $data->page_id;
$date = $data->date;
$event_longdesc = $data->event_longdesc;
$event_desc = $data->event_desc;

echo "<u>".$date."</u><br>".$event_desc;
echo "<div align=\"right\">".$event_longdesc."</div><br><br><br>";


}

if(!isset($eventsgefunden)) {
 echo "Heute finden leider keine Veranstaltungen statt";
}
echo "</div></div><div style=\"font-size:9px;\">Maus zum stoppen über Text bewegen</div><br>";

sorry for mixing german and english here and there.
only events from present date are displayed. otherwise a general message gets printed on the screen.

this is very basic and copy&pasted in a hurry but at least it works ;-) maybe this is useful for some of you...

have a nice sunday evening.
olli
Title: Re: display todays events from event-calender on frontpage
Post by: doc on June 10, 2007, 08:17:07 PM
Hi Olli,

thanks for sharing that piece of code.

Regards Christian
Title: Re: display todays events from event-calender on frontpage
Post by: Olli on June 10, 2007, 08:28:50 PM
no problem ;-)
feels good to give something back to the community. but the main work was done by PC-WACHT :-)

i forgot one thing: make sure to include the code inside the <head>....</head> area for the upscroll only on pages where needed! otherwise your page will not be valid anymore and contains errors.

just put this before the javascript and put the correct page id there:
Code: [Select]
<head>
....
<?php $page_id PAGE_ID; if ($page_id==3) { ?>
<script ...
....
</script>
<? } ?>
</head>
bye
Title: Re: display todays events from event-calender on frontpage
Post by: jschor on June 11, 2007, 10:49:59 AM
When this is finished can it be placed in the addons section as an "anyevent"-snippet??
Title: Re: display todays events from event-calender on frontpage
Post by: Olli on June 11, 2007, 12:54:51 PM
from my point of view this is finished. if anything is wrong or missing please let me know!

maybe i could do a module/installable addon of this which refers to an eventcaldender installation,  but i'm not sure how to handle the code between the <head>...</head>-tags inside a module yet, because this must be placed inside the template index.php file...

 
Title: Re: display todays events from event-calender on frontpage
Post by: doc on June 11, 2007, 01:55:54 PM
@Olli:
We have implemented a new function to WB v2.6.6 which allows to load external Javascript and CSS files for modules into the <head> section of the template. Once v2.6.6 is released, this should no longer be the show stopper  :-)

So start to create a installable module, I can help you with the integration of the JS code into the head section.

Regards Christian
Title: Re: display todays events from event-calender on frontpage
Post by: Olli on June 14, 2007, 11:05:05 PM
hey doc,

that's a very nice feature for WB to be able to control the <head> tag completly!

i will start to port this to a module the next days and will get back to you.

bye
Title: Re: display todays events from event-calender on frontpage
Post by: spawnferkel on June 15, 2007, 12:39:17 AM
Hi bakers,

I show my next five events from any event calender on my website with these code snipped in my template.

$termine = array();
$query = "SELECT event_desc, DATE_FORMAT(date,'%d.%m.%y') as date_formated FROM ".TABLE_PREFIX."mod_event_dates WHERE date >= NOW() AND  event_desc NOT LIKE '' ORDER BY date LIMIT 0, 5";
$result = mysql_query($query);
if(!empty($result)){
while($data = mysql_fetch_assoc($result)){
  $termine[] = $data;
}
if(!empty($termine)){
?><div id="termine">
<fieldset>
<legend>Termine...</legend><br />
<? foreach($termine as $termin){ ?>
<div style="border-bottom:1px solid #cccccc;"><strong>Am <?=$termin['date_formated']?></strong>
<p><?=$termin['event_desc']?></p>
</div>
<? } ?>
</fieldset>
</div><?
}
}

If you want to have a look to my solution you can find it in www.malteser-hagen-atw.de (http://www.malteser-hagen-atw.de). The events are displayed on the left site under the login-form.

Title: Re: display todays events from event-calender on frontpage
Post by: aggiedad on June 15, 2007, 03:22:26 PM
Spawnferkel,

This is great & I would like to put it on my site for my students' assignments. My question is: What field do I use to also show the event description?

Many thanks!

Don Simmons
Title: Re: display todays events from event-calender on frontpage
Post by: DGEC on June 15, 2007, 04:28:38 PM
This is great! I did this for my pre-WB calendar and was wondering when I was going to have the time to dive in and do this for WB :-)

Oh - wait - does it matter which calendar is this for? Do they all use the same database?  I'm using EventCalendar by Keijo Karvonen v1.1.1

I really don't like the look of the other two, and I've modified Keijo's a bit as well.
Title: Re: display todays events from event-calender on frontpage
Post by: Panther on June 15, 2007, 04:33:33 PM
@aggiedad
I haven't tested this, but looking at the database tables, this should work...

Code: [Select]
$termine = array();
$query = "SELECT event_desc, event_longdesc, DATE_FORMAT(date,'%d.%m.%y') as date_formated FROM ".TABLE_PREFIX."mod_event_dates WHERE date >= NOW() AND  event_desc NOT LIKE '' ORDER BY date LIMIT 0, 5";
$result = mysql_query($query);
if(!empty($result)){
while($data = mysql_fetch_assoc($result)){
  $termine[] = $data;
}
if(!empty($termine)){
?><div id="termine">
<fieldset>
<legend>Termine...</legend><br />
<? foreach($termine as $termin){ ?>
<div style="border-bottom:1px solid #cccccc;"><strong>Am <?=$termin['date_formated']?></strong>
<p><?=$termin['event_desc']?></p>
<p><?=$termin['event_longdesc']?></p>
</div>
<? } ?>
</fieldset>
</div><?
}
}

I modified this to use a different calendar and you can play with the formatting by editing the <p> tags and such surrounding the parts where it does the output. Also, you can change the format of the date in this piece DATE_FORMAT(date,'%d.%m.%y')

If you are unsure on how to formate it for the way you want, just do a google of php date format for what the different formatting variables are.

I hard-coded a link to my page with the actual event calendar on it...

I think I can figure how to find what the $page_id is of the page that has the event calendar, but is there a way to create a link to a page with it's url? That way a link could be added after the list, that would bring you right to the calendar...
Title: Re: display todays events from event-calender on frontpage
Post by: Panther on June 15, 2007, 04:42:07 PM
Oh - wait - does it matter which calendar is this for? Do they all use the same database?  I'm using EventCalendar by Keijo Karvonen v1.1.1

Yes, it does matter...
I'm not familiar with that calendar, do you have a link to it?

It is not difficult to change this to use any of the calendars, you just need to know what database table and fields to modify in the snippets.

I use a modified version of the Calendar by David ilicz Klementa, and took me five minutes to look up in my database and figure out which fields to change.
Title: Re: display todays events from event-calender on frontpage
Post by: DGEC on June 15, 2007, 05:25:10 PM
Yet Another Event Calendar.  It's a Month view

Keijok did a good job of it (i.e. implementing most of my wish list  :lol: ) He even has  :-o documentation!  Probably has the most documentation of anything besides showmenu2.

Not sure why it's not in the repository. Before putting in the repository, it really should have a name fully changed so it doesn't duplicate the existing EventCalendar name - if you install both, you end up with two "event calendar" entries to choose from, but at least it works.

http://forum.WebsiteBaker.org/index.php/topic,3777.0.html is the thread and
http://keijok.kapsi.fi/wb/pages/en/wb-modules/event-calendar.php?lang=EN is the documentation & download page

I went in and set a fixed height for the cells, I didn't like very short days if there was nothing for the week.

Looks like he hasn't been doing much on it lately. Hmm, although he has been here recently.

It is not difficult to change this to use any of the calendars, you just need to know what database table and fields to modify in the snippets.

I use a modified version of the Calendar by David ilicz Klementa, and took me five minutes to look up in my database and figure out which fields to change.
Cool, well this should be a good start for it, thanks!  He has a mini-calendar view already, this will be even more useful. 

Reminds me, there were a couple other things I wanted to tweak as well...
Title: Re: display todays events from event-calender on frontpage
Post by: aggiedad on June 16, 2007, 12:01:59 AM
Panther,

It works great! Thanks for the help. I am still just exploring MySQL.

Don Simmons

Title: Re: display todays events from event-calender on frontpage
Post by: Panther on June 16, 2007, 06:15:30 AM
@aggiedad

No problem, glad I could help.
I did programming for a few years waaaaay back in college, so I get the jist of things. But I know just enough javascript and php to get myself in trouble sometimes.
Title: Re: display todays events from event-calender on frontpage
Post by: spawnferkel on June 17, 2007, 01:04:13 PM
I had also installed the event calender with the month view, I thought it would be helpful for the users. But they all want the old version from the originally WebsiteBaker installation back because of the possibility to display all events on one site without any other cliks.

Bye
Title: Re: display todays events from event-calender on frontpage
Post by: vis-elu on August 28, 2007, 09:56:50 AM
Hello (@olli),

i failed to make your code work.
which header do you mean...(simply dont know where to paste it)

But

isn´t it possible just to display it in a code-area without scrolling & marquee?

Regards
Title: Re: display todays events from event-calender on frontpage
Post by: JTux on October 02, 2007, 11:52:39 AM
Yet Another Event Calendar.  It's a Month view

....
http://forum.WebsiteBaker.org/index.php/topic,3777.0.html is the thread and
http://keijok.kapsi.fi/wb/pages/en/wb-modules/event-calendar.php?lang=EN is the documentation & download page

I went in and set a fixed height for the cells, I didn't like very short days if there was nothing for the week.

<Snipped>
Reminds me, there were a couple other things I wanted to tweak as well...

Hello DGEC,

I have started to use the Event Calendar by Keijok, but the links to his website don't work anymore so I haven't been able to find any documentation. I would like to tweak some things like the height of cells in the main calendar and the mini calendars, but I don't know where to start. Can you please give me some pointers to how you do this?

Thanks

John
Title: Re: display todays events from event-calender on frontpage
Post by: DGEC on October 02, 2007, 05:14:44 PM
The Internet Archive's "Wayback Machine" is your friend.

Go to http://archive.org and enter the vanished page into the text box and you will shortly get a list of all the dates when they archived the page. The "*" tells you when they noticed differences in the page. Sometimes attachments like images don't get saved on one date, but do on others, so you might need to try a couple of different "identical" dates.

The first half of the documentation is how to use the calendar, the second half is CSS names and other coding display information. Cell height is not an option. Neither, is table with, I had to go in and manually set the overall table size to fit to my content width in a couple of places. Rats. I should have commented where I did that. I always forget that! I'm used to a SCL library at work, makes it easy to see where things have changed. Hmm. That would be nice to have in WB too...

As for the cell height, I forget how I did it - and I overwrote my experimental site so I have nothing to compare against.  I think I went into the php code where it writes out the table's cell definition and modified it to a set height.  Please post if you find the line to do that.
Start by looking at the view.php IIRC. 
The one problem with the modern tendency to write everything in different files is that it makes it harder to trace and find something without an IDE and debugger.

There's actually a ton of things I like to have it do differently, easist being putting the Add Event sub-form at the TOP of the page. When you have several pages worth of dates, it gets tiresome scrolling to the bottom every time. In fact, I'd like to modify it to display "pages" so that, i.e., only the current day/week/month/quarter's events are listed.
Even better, Adding or Editing events by clicking on the description or date in the calendar itself (for logged in administrators only of course) is also a vastly better interface than forcing you to the admin page all the time. The phpeventcalendar that I mentioned before is nice & easy to use like that, although it's not under development any more either and I never quite got to integrating it with WB before this one came out anyway. The project "webcalendar" is very powerful but harder to set up from what I can tell.

There's also issues with default time entry. I'd like to set a default time other than 9 - 4. And I think it was messing it up anyway, setting end time of 4 am or something - prior to the start time. Ahem. I just haven't got fixing any of that yet. I still haven't fixed my template rendering badly with FF in fact. Sigh.
Title: Re: display todays events from event-calender on frontpage
Post by: JTux on October 05, 2007, 03:44:58 AM
Thanks for the advice DGEC. I'll have a go at it but I'm pretty much a beginner with code so I'm sure how I'll go. I will post if I work it out!
Cheers,
John
Title: Re: display todays events from event-calender on frontpage
Post by: DGEC on October 05, 2007, 11:00:25 PM
All right! Got some progress here (even fixed my FF issues - did you know FF & IE handle the absence of a BODY statement differently? Go figure). And I didn't even remember to look at the docs  :roll:

I've modified several files, but the calendar.css file is the one to get a minimum fixed height, if you want nice clean code. Just add
Code: [Select]
height: 60px;or ems or whatever your design calls for in the calendar_day, calendar_eventday & calendar_today definitions. If that doesn't sell you on CSS... one line added to the 3 different types of cells vs adding a height to every <td> element?

I was also doing some adjusting of the font sizes and I converted the fixed pixel width to 94% or something like that (divide by 7 to get the size of the columns & adjust various fields to suit) - I had to cut the names down to short forms to get the width% to work - it's expandable, the same as the height!  (I was very confused - why are the column widths all different?? :-P) The languages/EN.php file contains the text strings for that.

You know, we probably should be discussing this in the mod_evcal thread.  Which, actually, is the point that Greg was making in his rant in the template management thread. There does need to be a wiki rather than just the message board so these kind of things could be added there and people pointed to the entries rather than rehashing multiple out-dated threads.
Title: Re: display todays events from event-calender on frontpage
Post by: erpe0812 on April 16, 2008, 11:38:30 AM
@spawnferkel:
where do I have to put this code in the template?
I tried to make a copy and paste to the template allcss2 but it did not worked.

erpe
Title: Re: display todays events from event-calender on frontpage
Post by: Olli on June 17, 2008, 04:36:26 PM
@vis-elu: do you still have problems with the code?
sorry just accidentally read it without having topic notification turned on.

just put the javascript stuff between <head>... </head>

that should do the trick

regards