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.

Template Questions

Changing background on each page without tons of templates


Reply

20 Posts   5385 Views

Avatar
Martijn

22 January 2010 at 10:47am Community Member, 271 Posts

We all had to start somewhere :)....

If this is your Background:

$fields->addFieldToTab('Root.Content.Main', new ImageField('Background'));

You dont't need my Image field....

It should be there in the cms, if you've added this to Page.php

public function getCMSFields(){
$fields = parent::getCMSFields();
// add the upload control for the background image to the cms
$fields->addFieldToTab('Root.Content.Main', new ImageField('Background'));
return $fields;
}

You can give it a new tab by changing Root.Content.Main to Root.Content.Background

Avatar
evsoul

22 January 2010 at 2:12pm Community Member, 36 Posts

Where should the "background uploader" field show up?

I tried changing it from Root.Content.Main to Root.Content.Background to see if it would make any difference and it didn't.
Is there anything like the ?flush=1 that I need to do so that it rescans all of that Page.php file?

I'm doing it exactly as I'm reading and not seeing any extra fields.. but maybe I'm not looking in the right place. I assume if I do the Root.Content.Background it would show up as another tab next to Main and Metadata? I did that and it doesn't show up and even tried sitename.com/admin/?flush=1 just to see.. and I tried changing it back to Root.Content.Main and do not see anything under the main tab for each page..

Any thoughts as to what I could be doing wrong? Or where I should be looking?

Thanks a lot!

-Greg

Avatar
Martijn

22 January 2010 at 2:23pm Community Member, 271 Posts

hm, could you pastie.org your code?

Avatar
evsoul

22 January 2010 at 2:48pm Community Member, 36 Posts

oh cool never used pastie before! very cool.

Page.php: http://pastie.org/789234

Avatar
Martijn

22 January 2010 at 11:32pm Community Member, 271 Posts

getCMSFields needs to be in class Page instead of class Page_Controller.

Avatar
evsoul

23 January 2010 at 6:57am Community Member, 36 Posts

Awesome! See I have no knowledge of php :-/ but once my schedule opens up a bit I will try to learn some basics to start off.

I now get the background upload field below the WYSIWYG text field but when I upload an image I get a very quick flash of some error then it goes back to the uploader field. So I tried "attach from file store" and there the image was in "uploads" directory I selected it and I get this error:

"Website Error
There has been an error

The website server has not been able to respond to your request."

in the box where the background uploader field is.

Any thoughts?

And thanks a lot for the help!

Avatar
evsoul

26 January 2010 at 10:19am Community Member, 36 Posts

Been a few days with no reply so wanted to bump the thread if that's ok.

Does anyone know what could cause the error:

"Website Error
There has been an error

The website server has not been able to respond to your request."

when trying to select an already uploaded background image?
I went to the uploads directory and the image had been uploaded successfully when I viewed it.

Avatar
Martijn

26 January 2010 at 10:53am Community Member, 271 Posts

Website error could really mean anything....

Check your server error logs for more information and make shure your site is in devmode.