Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

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

Help with header


Go to End


24 Posts   6232 Views

Avatar
Webdoc

Community Member, 349 Posts

7 November 2009 at 10:47am

U wanna have tab where u can change the banner image in everypage??

Avatar
steve_nyhof

Community Member, 224 Posts

7 November 2009 at 11:14am

Thank you for the reply, I have this all working now.

Avatar
HanSolo

Community Member, 87 Posts

27 November 2009 at 4:13am

Hi used the

public static $has_one = array(
'FlashBanner1' => 'File'
);

function getCMSFields() {
$fields = parent::getCMSFields();

$fields->addFieldToTab('Root.Content.Banner', new FileIFrameField('FlashBanner1'));

return $fields;
}
}
in mysite/code/page.php
but when i try to acccess the cms i get website error. Have I missed something

Joakim

Avatar
Martijn

Community Member, 271 Posts

27 November 2009 at 4:38am

Edited: 27/11/2009 5:16am

What error?

I got a cant handle suburls when using SiteTree::enable_nested_urls(); in 2.4.

Diable the nested urls made the uploadfield work again.
Edit:: this is nog a nested_urls related error, but a translatable error...

Avatar
steve_nyhof

Community Member, 224 Posts

27 November 2009 at 6:17am

Edited: 27/11/2009 6:17am

This is my code in the code>Page.php file

class Page extends SiteTree {

public static $db = array(
);

public static $has_one = array(
"HeaderImage" => "Image"
);

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new ImageField("HeaderImage", "Header Image"));

return $fields;
}

}

Avatar
HanSolo

Community Member, 87 Posts

27 November 2009 at 11:31pm

I used the same code but still an error. I checked the error log on the server and it said that the editor.css was missing, so I took it from the blackcandy template and moved it over to the server but still the same error?

Joakim

Avatar
Chrisazuka

Community Member, 20 Posts

9 December 2009 at 4:01am

Edited: 09/12/2009 4:06am

Hello Aram,

You tip on the unique header image for pages has really help me alot. In continuation of puting unique Image or Flash header, I will really appreciate if you can help me with how i can upload not just 1 image but multiple images for each page and use the images in a with this javascript image slider: http://www.gruppo4.com/~tobia/cross-slide.shtml (CrossSlide is a jQuery plugin for image animation slideshow)

I have tried to use the javascript code directly inside the template but didn't work, the image or how i can use it directly with the image gallery module which seems like further maths to me, very dificult. I have very new with SilverStripe, great product.

What i want to achieve is unique/ different Image slideshow on the Header of my pages, the diffrent pages will have diffrent image header slider.

Please any help will be appreciated from you guys, expecially with using the CrossSlide javascript image slider: http://www.gruppo4.com/~tobia/cross-slide.shtml (Ken Burns effect)

Avatar
Carbon Crayon

Community Member, 598 Posts

9 December 2009 at 4:51am

Edited: 09/12/2009 4:52am

Hi Crisazuka

This plugin seems to be a bit unconventional in that it defines the image locations within the script itself...not really a great way to do it but anyway.....

To get it to work you will need to define the script from within the init() function of your Page_Controller class. You can then get the URLs of the images you have defined in the $has_one relationship.

e.g.:

	public function init() {
		parent::init();
				
		Requirements::javascript("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js");
                Requirements::javascript("mysite/javascript/jquery.cross-slide.js");
		Requirements::customScript("
			jQuery('#test1').crossSlide({
			  speed: 45,
			  fade: 1
			}, [
			  { src: '" . $this->Image1()->URL . "', dir: 'up'   },
			  { src: '" . $this->Image2()->URL . "',   dir: 'down' },
			  { src: '" . $this->Image3()->URL . "',  dir: 'up'   },
			  { src: '" . $this->Image4()->URL . "', dir: 'down' }
			]);		
		");			

	}

}

To make it work with a $has_many relationship (i.e. an Image Dataobject manager) would be a little more complicated, basically you would need to create a loop to loop through each of the images and define the path which given the structure of the definition isn't immediately obvious, I think you would need to generate the definition with a function and then insert it into the page....probably more hassle than it's worth :)

Anyway I hope that helps

Aram

Go to Top