Remember me? forgot password | register

SilverStripe Forum

4712 Posts in 1055 Topics by 670 members

Jump to:

Extending and hacking

If this is your first visit, you will need to register before you can post. However, you can browse all messages below.

Community » SilverStripe Forum » Extending and hacking » Adding a php slideshow
Page: 1 go to end Reply
Author Topic: Adding a php slideshow 557 views
  • luisq
    avatar
    Community Member
    7 posts

    Adding a php slideshow Link to this post

    Hello there,
    I'm trying to add a slideshow to my site that I got online. I got it to make it appear on the place that I want it using this code:

    mysite/code/HomePage:

    class HomePage_Controller extends Page_Controller {

       function Content() {
        return str_replace('$slideshow', $this->slideshow(), $this->Content);
       }

       function slideshow() {
        return include('slideshow.php');
       }

    }

    so by that I'm able to show it (include it) on the part that I want. But when it comes on the site, it appears all the way to the top, and it only appear a number 1 where it suppose to be the slideshow. You can look at it here:

    http://sitesimpleonline.com

    I try to change the styles of the div, add a new div and put it inside, try everything with CSS but I think that it's not the problem =(

    Any help, comments, manuals, etc will be REALLY appreciated!

    THANK YOU very much!!!

    Last edited: 6 September 2008 at 5:31pm

  • simon_w
    avatar
    Community Member
    191 posts
    3 SilverStripe Sites

    Re: Adding a php slideshow Link to this post

    What you could do is wrap the contents of slideshow.php in a function, which you can call. Instead of using echo/print/printf in that function, you'll want to return all output. Depending on how you do this, you may need to append the output to a variable and then return the variable, or, if there's only one output call, change it to return;

    Then change the slideshow() method to something like:

    function slideshow() {
    include_once('slideshow.php');
    return slideshowFunc();
    }

    Last edited: 6 September 2008 at 9:23pm

  • luisq
    avatar
    Community Member
    7 posts

    Re: Adding a php slideshow Link to this post

    Thanx simon but didn't make it, the slideshow has to many prints, echos, returns and to many files taht are being include = (

    So I'm trying to use a simple <iframe>, but for some reason SS doesn't like iframes and makes a mess of the page this is what I'm using:

    <?php
    /**
    * Defines the HomePage page type
    */

    class HomePage extends Page {

    }

    class HomePage_Controller extends Page_Controller {

       function Content() {
        return str_replace('$slideshow', $this->slideshow(), $this->Content);
       }

       function slideshow() {
           $show = '<iframe src="http://sitesimpleonline.com/demoslideshow.php">';
          return $show;
       }
    }
    ?>

    any suggestion??? =P

    Thnx again!

  • simon_w
    avatar
    Community Member
    191 posts
    3 SilverStripe Sites

    Re: Adding a php slideshow Link to this post

    The iframe needs to be closed, so replace

    <iframe src="http://sitesimpleonline.com/demoslideshow.php">
    with
    <iframe src="http://sitesimpleonline.com/demoslideshow.php" />

    You may also want to specify the width and height of the iframe.

  • luisq
    avatar
    Community Member
    7 posts

    Re: Adding a php slideshow Link to this post

    Thank you very much simon!
    for some reason this didn't worked:

    <iframe src="http://sitesimpleonline.com/demoslideshow.php" />

    but like this it did (even though it's not correct...)

    <iframe src="http://sitesimpleonline.com/demoslideshow.php"></iframe>

    but "the end justifies the means" lol

    Thanx again!

    557 views
go to top Reply

Currently Online:

contigo, w1, Fading, motoservo

Welcome to our latest member: jewelbd