Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: jamesgrant on November 25, 2004, 06:55:13 PM

Title: Changing the SSI Calendar Output
Post by: jamesgrant on November 25, 2004, 06:55:13 PM
hello...

I'm currently using the <!--#include virtual="./SSI.php?ssi_function=todaysEvents" --> in my shtml front page of my website to display the calendar...
I'm using it to display all the events coming up in the next 28 days.

It's a great feature, but when it's output onto my webpage, it's all in one long line. Ok, it's separated by commas, but i would love it to have 1 event to a line...

better still, could each event output be put into bullet points????

I was wondering if anyone knows of any way i can modify something to enable it to come out in a list, rather than a line????

::) ??? ::)

James


Edited by: A.M.A
How to do it: Please read (Reply #8)
Title: Re: Changing the SSI Calendar Output
Post by: Grudge on November 25, 2004, 07:22:02 PM
Why not include it using PHP (Check ssi_examples.php), you can then return the results of the function as an array, and then process it yourself. You'll want to refer to the example file for how to include it as PHP, and then also check out the function in SSI.php to see how the array looks, to give you an idea something like this is an idea:

include('SSI.php');
$result = array();
todaysEvents($result);
echo '<ul>';
foreach ($result as $event)
echo '<li>' . $event['name'] . '</li>';
echo '</ul>';


Note that won't work as I haven't checked the function name and/or what is in the array but it's an idea, I'm sure someone else can help if needed - I'm off to bed
Title: Re: Changing the SSI Calendar Output
Post by: jamesgrant on November 26, 2004, 11:34:34 AM
Thanks for that grudge :)

i do understand that, but have no idea what variables or anything like that i need to use at all to get it work  ::)

So yeah, if anyone does know how to di it, that would be amazing lol

cheers

Jay  8)
Title: Re: Changing the SSI Calendar Output
Post by: Grudge on November 26, 2004, 11:42:06 AM
What about this - should work I think:

<?php
include('SSI.php');
$result ssi_todaysEvents('array');
if (!empty(
$result))
{
echo 
'<ul>';
foreach (
$result as $event)
echo 
'<li>' $event['link'] . '</li>';
echo 
'</ul>';
?>

}


If it isn't in the same directory as your forum you may need include('forum/SSI.php') etc
Title: Re: Changing the SSI Calendar Output
Post by: jamesgrant on November 26, 2004, 06:04:02 PM
Thanks for that grudge...

I've tried it out though, and it doesnt seem to work  :( just has a blank space  :( :(

I've swapped the

}
?>

around though, cos that looks like it's round the wrong way???
Still doesnt work tho :(

The page i'm trying to use it in is a .shtml file... would that make any difference? i know you have little 'php' areas... but is it going to 'compile' right as it's .shtml? would it be handled differently by my server? or am i just talking about something i know nothing about really  ::)  :P
Title: Re: Changing the SSI Calendar Output
Post by: [Unknown] on November 27, 2004, 02:48:54 AM
Name this file "calendar_include.php" and put it in the forum's directory:

<?php

include(dirname(__FILE__) . '/SSI.php');

$result ssi_todaysEvents('array');
if (!empty(
$result))
{
   echo 
'
      <ul>'
;
   foreach (
$result as $event)
      echo 
'
         <li>'
$event['link'], '</li>';
   echo 
'
      </ul>'
;
}

?>


Then, include it like so:

<!--#include virtual="./calendar_include.php" -->

Your whole site doesn't have to be PHP to use PHP ;).

-[Unknown]
Title: Re: Changing the SSI Calendar Output
Post by: Grudge on November 27, 2004, 06:32:27 PM
...and sorry for getting the ?> and } the wrnog way around... that's what you get for rushing :P
Title: Re: Changing the SSI Calendar Output
Post by: jamesgrant on November 28, 2004, 01:34:09 PM
lol no worries grudge  ;)

Thanks for that too [unknown].... but that doesnt work either!!!

Bit closer to a result though: i have bullet points on the screen, but nothing else  >:( :'(

And i've checked, it isnt the font colour the same as the background colour or anything like that... it's just not there at all! :(

Title: Re: Changing the SSI Calendar Output
Post by: [Unknown] on November 28, 2004, 07:57:38 PM
Name this file "calendar_include.php" and put it in the forum's directory:

<?php

include(dirname(__FILE__) . '/SSI.php');

$result ssi_todaysEvents('array');
if (!empty(
$result))
{
   echo 
'
      <ul>'
;
   foreach (
$result as $event)
      echo 
'
         <li><a href="' 
$event['href'] . '">' $event['title'] . '</a></li>';
   echo 
'
      </ul>'
;
}

?>


Then, include it like so:

<!--#include virtual="./calendar_include.php" -->

-[Unknown]
Title: Re: Changing the SSI Calendar Output
Post by: jamesgrant on November 29, 2004, 03:48:02 AM
Wicked lol.... that works


Cheers for that [unknown]  ;D
Title: Re: Changing the SSI Calendar Output
Post by: Roger on January 09, 2005, 04:12:19 PM
Is it possible to inclue de date in that list?  What would be the variable for that?

Thanks,
Roger
Title: Re: Changing the SSI Calendar Output
Post by: [Unknown] on January 11, 2005, 07:52:46 PM
Quote from: Roger on January 09, 2005, 04:12:19 PM
Is it possible to inclue de date in that list?  What would be the variable for that?

Thanks,
Roger

I'm afraid there's no date available, but there probably should be.

-[Unknown]
Title: Re: Changing the SSI Calendar Output
Post by: Roger on January 13, 2005, 12:52:58 AM
Thanks for the clarification Unknown.

Does this mean we might see a variable for that in a future version?

Cheers,
Roger
Title: What if the calendar is empty?
Post by: jamesgrant on January 23, 2005, 02:53:23 PM
If there are no events to display within the set time frame (mine is currently set to display events within the next 30 days), the bit where my events would be is empty.

Is there any way to display a "there are currently no events available within the next 30 days" type thing bit of text if it doesnt pull any dates from the calendar??
Title: Re: What if the calendar is empty?
Post by: bcswebco.com on March 07, 2005, 11:58:10 AM
Quote from: jamesgrant on January 23, 2005, 02:53:23 PM
If there are no events to display within the set time frame (mine is currently set to display events within the next 30 days), the bit where my events would be is empty.

Is there any way to display a "there are currently no events available within the next 30 days" type thing bit of text if it doesnt pull any dates from the calendar??

Yes ... try this code for the calendar_include.php file.

It is the same as what was posted by [Unknown]  ... with an "else" statement added to cover if no events are scheduled.   

How many days the system looks ahead is determined in the layout settings of the board.

<?php

include(dirname(__FILE__) . '/SSI.php');

$result ssi_todaysEvents('array');
if (!empty(
$result))
{
   echo '
      <ul>'
;
   foreach ($result as $event)
      echo '
         <li><a href="' 
$event['href'] . '">' $event['title'] . '</a></li>';
   echo '
      </ul>'
;
}
else
      echo '
         <br>There are currently no events<br><br>'
;

?>



Modify

<br>There are currently no events<br><br>

as needed for your site.
Title: Re: Changing the SSI Calendar Output
Post by: jamesgrant on March 13, 2005, 04:16:15 PM
thanks  8) 8)
Title: Re: Changing the SSI Calendar Output
Post by: Gwion on March 23, 2006, 01:06:17 PM
I have tried what you say in this thread but unfortunately I couldn't get it to work.
When I call the SSI.php funciton it's fine, also when I call up calendar_include.php it shows the test entry I put in the calendar.
When I put this code <!--#include virtual= code in my html file it does not do anything.
The ssi_examples.shtml page however works fine.

I have not used SSI before but I assume my html file must be in the SMF directory? How must I change it (or what and where) so the html can stay in the top level directory?

Title: Re: Changing the SSI Calendar Output
Post by: mgjohns on April 06, 2006, 09:53:38 PM
If your file extension is .html the "include" statement will not work.  Change the .html to .shtml and see if that works.  The location of the file itself is not that important.  Also, you need to ensure you have the path to the included file correct.

Some examples:
calendar.php is located in web_root/smf directory
myfile.shtml is located in web_root directory
Then you would need this:  <!--include virtual "smf/calendar.php"-->

calendar.php is located in web_root/smf directory
myfile.shtml is located in web_root/mydirectory directory
Then you would need this:  <!--include virtual "../smf/calendar.php"-->
Title: Re: Changing the SSI Calendar Output
Post by: lyngenielsen on September 10, 2007, 05:45:10 AM
Hi all ....

I had the same Q - and here You all have giving a nice solution.
But - is the an webpage where I can see the output of these different solution You have given here in this topic?

\Michael
Title: Re: Changing the SSI Calendar Output
Post by: lyngenielsen on September 10, 2007, 03:55:35 PM
Hi Guys ...

May I ask inhere?

I' va tryed to use the solutions you have given here, but have some failure.
(My coding is crap)  :-[


On this link: http://www.isore.dk/forum/calendar_include.php (http://www.isore.dk/forum/calendar_include.php) - the script works fine.

How come, when I use this <!--#include virtual="../forum/calendar_include.php" --> on the first indexpage on this link: http://www.isore.dk/index.php (http://www.isore.dk/index.php) - see under Kommende kalender "Events": (left bottom) - then it DOSNT work?

I use <?php require("forum/SSI.php"); ?>   on each php page.

Can You help me?
Title: Re: Changing the SSI Calendar Output
Post by: lyngenielsen on September 10, 2007, 04:01:33 PM
By the way - the <?php ssi_todaysEvents(); ?> is also in action on the index.php page - please dont think this is correct output.
As u can see - its uses "comma (,)" and not the correct output as seen on http://www.isore.dk/forum/calendar_include.php (http://www.isore.dk/forum/calendar_include.php)
Title: Re: Changing the SSI Calendar Output
Post by: Fiery on October 10, 2007, 01:47:09 AM
Wow this was a really old topic that was dug up.  Many things have changed since that version of SMF.

It would be easier if one of you started a new topic, described exactly what you want to do, and told us your SMF version.

Thanks
Title: Re: Changing the SSI Calendar Output
Post by: myaicons on January 28, 2008, 10:05:38 PM
i agree... lets go look for other topics in the forum dealing with SSI calendar or board outputs... do it.  better yet... maybe we can answer a few of them.