Jump to:

10854 Posts in 2518 Topics by 1794 members

All other Modules

SilverStripe Forums » All other Modules » Calling a Module directly into HomePage.ss

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1374 Views
  • Mrfixer
    Avatar
    Community Member
    49 Posts

    Calling a Module directly into HomePage.ss Link to this post

    I have Nivoslider module running lovely on my site but only as long as i go create a slider in CMS using the NivoSliderPage, not a problem apart from the fact that i would like not to have to go to http://www.mysite.com/nivosliderpage/ to see it, what i want to do is show the slider onto my HomePage.

    I thought this might work:

    In CMS create a new Nivoslider page and in Behavior have it not to show in Menus

    and then

    Copy the nivoslider .ss files from inside the nivoslider modules templates/Includes and templates/Layout folders and pop them into my themes templates/Includes and templates/Layout and use an include from my themes HomePage.ss to call the NivoSliderContainer.ss

    But all i get is an empty div showing where the slider should be going, how can i get this to work short of ripping the code from the Modules NivoSliderPage.php file and integrating into my HomePage.php?

    Regards

  • Webdoc
    Avatar
    Community Member
    329 Posts

    Re: Calling a Module directly into HomePage.ss Link to this post

    Its easier to make your own pagetype for nivoslider and add your own code to HomePage.ss
    HomePage.php under mysite/code

    <?php
    /**
    * Defines the HomePage page type
    */
    class HomePage extends Page {
    static $db = array(
    );
    static $has_one = array(
    );

    static $allowed_children = array('Slide');
    }

    class HomePage_Controller extends Page_Controller {

    }

    ?>

    Slide.php same place as HomePage.php

    <?php
    /**
    * Defines the Slide page type
    */
    class Slide extends Page {
    static $db = array(
    );
    static $has_one = array(
       'Photo' => 'Image'
    );
    function getCMSFields() {
    $fields = parent::getCMSFields();
       $fields->addFieldToTab('Root.Content.Main', new ImageField('Photo'), 'Content');
    return $fields;
    }
    }

    class Slide_Controller extends Page_Controller {

    }

    ?>

    And in your Layout/Homepage.ss add:

    <div class="typography">
       <div id="slider1" class="nivoSlider">
          <% control AllChildren %>
                <img src="$Photo.URL" alt="$Title" title="$Title">            
          <% end_control %>
       </div>
    </div>

    also u can add fixed width to image if u wanna.

  • Mrfixer
    Avatar
    Community Member
    49 Posts

    Re: Calling a Module directly into HomePage.ss Link to this post

    Hey WebDoc.. your a star, many, many thanks, i managed to get it working in about 2 minutes with the help of the code you supplied, there was one line staring me right in the face..

    static $allowed_children = array('NivoSliderPage');

    now that worked, but wouldnt let me save settings from the Slider Settings panel in the Module, but how you laid your code out finally helped me to knock up the NivoSliderPage.php caode into my existing HomePage.php file without having to allow children

    again thanks..

  • Webdoc
    Avatar
    Community Member
    329 Posts

    Re: Calling a Module directly into HomePage.ss Link to this post

    U welcome i am also not a pro but happy to help

  • greenpea
    Avatar
    Community Member
    19 Posts

    Re: Calling a Module directly into HomePage.ss Link to this post

    Hi, I've tried out this code using the latest trunk build for Nivo Slider module, using SilverStripe 2.4.5.

    I can create a slide child underneath the homepage. The slide page type only lets me add one image. This means the slider appears as a static image.

    How can I amend slide.php, or homepage.ss to display images as a slider?

    Thanks

  • Naren
    Avatar
    Community Member
    21 Posts

    Re: Calling a Module directly into HomePage.ss Link to this post

    Hi all,

    I have installed silverstripe 3.0 and also nivo slider with this, it was installed successfully, on admin I can function it very well.

    But I dont know how to use this on my home page. I used various code to installed but failed. Can any one suggest me the right way how to use this one.

    My theme structure is template/page.ss and Layout/page.ss

    I have created the Homepage.ss under the layout folder as well, But dont know how to call it on home page.

    Please guide me how to show it on the homepage.

    Thanks in advance.

    1374 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.