Remember me? forgot password | register

SilverStripe Forum

4713 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 » How to add custome PHP pages
Page: 1 go to end Reply
Author Topic: How to add custome PHP pages 719 views
  • luisq
    avatar
    Community Member
    7 posts

    How to add custome PHP pages Link to this post

    Hello everyone!

    I'm really new with CMS, and I'm trying to add a page that has PHP. Something like this:

    <?php
    // START of "Frontpage Slideshow" settings
       $nameOfSlideshowToDisplay = "demoslideshow";                // Enter the name of your slideshow. Slideshows are in folders inside /fpss/slideshows/.
       $URLofyoursite = "http://sitesimpleonline.com";                   // Enter your site's URL.
       $AbsoluteServerPathofyoursite = "/home/hsphere/local/home/wwwuser/sitesimpleonline.com";      // Enter the root path of your site on the server.
       
       // do not edit below this line
       include_once($AbsoluteServerPathofyoursite."/fpss/mod_fpslideshow.php");
    // END of "Frontpage Slideshow" settings
    ?>

    This code it's to insert a slideshow that I bought. And I want to put it in the home page. I went through the manuals to add modules, but I don't want to add it as a module, just as a custom home php page. It's there anyway that I can do that? if there is a manual for it, can somebody provide me the link =(

    I was able to this using joomla! by adding a tag like this {jumi [includes/slideshow.php]} in an article. It's there any tag that I can add in my home page article to "include" a php page?

    Thank you very much for the HELP!!

    Last edited: 12 August 2008 at 6:46am

  • willr
    avatar
    Core Development Team
    1274 posts
    3 SilverStripe Sites 2 SilverStripe Themes

    Re: How to add custome PHP pages Link to this post

    tutorial 1 and 2 cover adding page types. The first one shows you how to make a 'HomePage' page type which sounds like what you want to do :).

    [1] http://doc.silverstripe.com/doku.php?id=tutorial:1-building-a-basic-site

  • Sean
    avatar
    Core Development Team
    438 posts
    1 SilverStripe Site 1 SilverStripe Theme

    Re: How to add custome PHP pages Link to this post

    Like willr said, you'll want to create a custom page type, then you'll probably want to include your custom PHP script whenever the page type is initialized:

    e.g. HomePage.php inside mysite/code:

    class HomePage extends Page {

    }

    class HomePage_Controller extends Page_Controller {

       function init() {
          parent::init();

          // Specify our custom PHP file for inclusion on this page
          include('my/path/to/file.php');
       }

    }

    init() is called on any controller class when that page type is initialized (i.e. when the controller is invoked by someone viewing a page with that page type applied to it).

    Hope this helps!

    Sean

  • luisq
    avatar
    Community Member
    7 posts

    Re: How to add custome PHP pages Link to this post

    Thank you for the help, I almost about to get it. Now I have this problem, inside the file that I'm including I'm using 'echo', normal text and some html tags, so I get this error:

    XML Parsing Error: syntax error
    Location: http://sitesimpleonline.com/
    Line Number 1, Column 1:

    Title<?xml version="1.0" encoding="UTF-8"?>
    ^
    Also how can I Include html tags, for example and iframe?
    thank you!!

    Last edited: 13 August 2008 at 4:42am

  • luisq
    avatar
    Community Member
    7 posts

    Re: How to add custome PHP pages Link to this post

    Thank you willr and Sean! I was able to figure it out with this post:

    http://doc.silverstripe.com/doku.php?id=recipes:customising-content-in-your-templates&s=paypal

    Pretty interesting how SS works! Once again thanx for all the help...

    719 views
go to top Reply

Currently Online:

simon_w, Fading, willr

Welcome to our latest member: jewelbd