Jump to:

3397 Posts in 978 Topics by 854 members

Template Questions

SilverStripe Forums » Template Questions » splash page / intro page

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2049 Views
  • HanSolo
    Avatar
    Community Member
    83 Posts

    splash page / intro page Link to this post

    I have a question I want a splash page/intro page before normal site, the splash intro page is totally different in design from the other pages. Is this possible I want the splash page to show for 5 sec and use meta content redirect so I can redirect it to the normal page. Cant figure out how to do that.

    Joakim

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: splash page / intro page Link to this post

    Course its possible! did you want the splash page to show on every page before you visit it ? eg if a visitor hits yoursite.com/news-article did you want to show the splash page or just for hits to the homepage? How I would do it is have another theme for your splash page. Then based on a cookie (or session var) set the theme to that one or the normal one.

  • HanSolo
    Avatar
    Community Member
    83 Posts

    Re: splash page / intro page Link to this post

    Hi willr, I just want it when the visitors hit the homepage, i am not that familiar with programming, where would i set a session variable, i have tried to do it with a meta content redirect but that did not work

    Joakim

  • MarkAB
    Avatar
    Community Member
    30 Posts

    Re: splash page / intro page Link to this post

    Hi Willr,

    I'd also like to do this too, do you have anymore info/advice on being able to apply a separate template just to the Intro page please?

    Thanks in advance!!

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: splash page / intro page Link to this post

    MarkAB / HanSolo if you have a custom page type for your homepage its easiest. How you could do it is overview the forTemplate() function to use another template for the initial load.

    Not sure if both of you want exactly the same thing but you can try

    // mysite/code/HomePage.php -> HomePage_Controller

    function forTemplate() {
    if(Cookie::get('ShownIntro') {
    // already visited the intro, show t
    Cookie::clear('ShownIntro');

    return $this->renderWith(array($this->class, 'Page'));
    else {
    // never visited, show the intro page
    Cookie::set('ShownIntro', true);

    return $this->renderWith(array('Intro', 'Page'));
    }
    }

    Then have an Intro.ss template for the Intro page.

  • Richi
    Avatar
    Community Member
    16 Posts

    Re: splash page / intro page Link to this post

    Sorry to dig out this old thread, but I thought it's better than creating a new one.

    I'm exactly in need of the same thing, showing a disclaimer to people who visit the site before they see anything else.
    I tried to do it with a jquery cookie method, but it doesnt seem to work inside silverstripe ...

    What Willr posted there seems to be the right thing:

    // mysite/code/HomePage.php -> HomePage_Controller

    function forTemplate() {
    if(Cookie::get('ShownIntro') {
    // already visited the intro, show t
    Cookie::clear('ShownIntro');

    return $this->renderWith(array($this->class, 'Page'));
    else {
    // never visited, show the intro page
    Cookie::set('ShownIntro', true);

    return $this->renderWith(array('Intro', 'Page'));
    }
    }

    3 questions about this:

    1) would I have to write this in all of my page types classes (homepage.php, page.php, articleholder.php etc.) if I wanted to show it on every possible point of entering the page of the site?

    2)

    function forTemplate() {
    if(Cookie::get('ShownIntro') {
    // already visited the intro, show t
    Cookie::clear('ShownIntro');

    do this few lines already set a fully viable cookie "shownintro", how would you let it expire after e.g. 14 days of not visiting my site?

    3) Is this method working in SS 2.4.6?

    I'd be happy if someone with knowledge could post an answer here

    best regards, Richi

  • martimiz
    Avatar
    Forum Moderator
    1038 Posts

    Re: splash page / intro page Link to this post

    Hi Richi,

    1. If all your pagetypes extend the Page class (which normally they would), I think you'd only need to add it to your Page_Controller to be effective on every pagetype

    2. As for the cookie: Cookie::set() accepts the following parameters:

    static function set($name, $value, $expiryDays = 90, $path = null, $domain = null, $secure = false, $httpOnly = false)

    3. I see no reason to believe it wouldn't work in 2.4.6 - you could always just try it out

    Martine

  • Richi
    Avatar
    Community Member
    16 Posts

    Re: splash page / intro page Link to this post

    Thx for the tip martimiz, sorry one last question, would this code be put anywhere in between of the openening { and the closing } of class Page_Controller extends ContentController because dreamweaver highlights some lines as syntax error ... ?

    I think I'm in the wrong place.

    class Page_Controller extends ContentController {

       /**
        * An array of actions that can be accessed via a request. Each array element should be an action name, and the
        * permissions or conditions required to allow the user to access it.
        *
        * <code>
        * array (
        * 'action', // anyone can access this action
        * 'action' => true, // same as above
        * 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
        * 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
        * );
        * </code>
        *
        * @var array
        */

    function forTemplate() {
    if(Cookie::get('ShownIntro') { /// highligs syntax error
    // already visited the intro, show t
    Cookie::clear('ShownIntro');

    return $this->renderWith(array($this->class, 'Page'));
    else { /// highlights syntax error
    // never visited, show the intro page
    Cookie::set('ShownIntro', true);

    return $this->renderWith(array('Intro', 'Page')); /// Would I substitute 'Intro' with 'DisclaimerPage' if my template is named DisclaimerPage.ss ?
    }
    }

       public static $allowed_actions = array ( /// highlights syntax error
       );

       public function init() { /// highlights syntax error
          parent::init();

          // Note: you should use SS template require tags inside your templates
          // instead of putting Requirements calls here. However these are
          // included so that our older themes still work
          Requirements::themedCSS('layout');
          Requirements::themedCSS('typography');
          Requirements::themedCSS('form');
       }
       
    } /// highlights syntax error

    2049 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.