10379 Posts in 2194 Topics by 1710 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1011 Views |
-
Calling a Module directly into HomePage.ss

6 July 2011 at 3:30am
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
-
Re: Calling a Module directly into HomePage.ss

6 July 2011 at 9:10am
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.
-
Re: Calling a Module directly into HomePage.ss

6 July 2011 at 7:51pm Last edited: 7 July 2011 1:08am
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..
-
Re: Calling a Module directly into HomePage.ss

23 July 2011 at 5:26am
U welcome i am also not a pro but happy to help
-
Re: Calling a Module directly into HomePage.ss

18 September 2011 at 4:39pm
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
| 1011 Views | ||
|
Page:
1
|
Go to Top |



