17488 Posts in 4473 Topics by 1978 members
| Go to End | Next > | |
| Author | Topic: | 2284 Views |
-
SideBar images

23 November 2008 at 12:18am
I have a sidebar working using the following code:
class Page extends SiteTree {
static $db = array(
'Sidebarcontent' => 'HTMLText'
);
static $has_one = array(
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Sidebar', new TextareaField('Sidebarcontent'), 'HTMLText');return $fields;
}
}This is placed in the sidebar page using $Sidebarcontent.XML
I want to be able to put images in here as well, but currently when I try this it just places the link.
Can anyone help me make the sidebar display text and images?
-
Re: SideBar images

23 November 2008 at 8:44am
You'd probably want to use an htmleditorfield for the sidebar, since you're setting it up that way in the db creation and then you can use tinymce to format it.
$fields->addFieldToTab('Root.Content.Sidebar', new HtmlEditorField('Sidebarcontent', 'Sidebar Content'));
Then call it as $Sidebarcontent
-
Re: SideBar images

23 November 2008 at 9:41am
Thanks for your help, I have edited it to the following:
class Page extends SiteTree {
static $db = array(
'Sidebarcontent' => 'HTMLText'
);
static $has_one = array(
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Sidebar', new HtmlEditorField('Sidebarcontent', 'SidebarContent'));return $fields;
}
}But it is showing the HMTL as code. What do I do from here? How would I go about using tinymce to format it?
-
Re: SideBar images

23 November 2008 at 10:16am
Are you using $Sidebarcontent in the template, or $Sidebarcontent.XML?
-
Re: SideBar images

23 November 2008 at 10:18am
I have tried both, and have now changed it to $Sidebarcontent
-
Re: SideBar images

23 November 2008 at 12:46pm
How do I use tinymce to format it?
I cant work out how to get the images and text to show properly. -
Re: SideBar images

23 November 2008 at 11:48pm
I am really stuck on this, can anyone help?
why is the code not formatting properly? no styles or images are showing -
Re: SideBar images

24 November 2008 at 3:31am
Can you clarify exactly what you are seeing rendered on the page?
If the field is an HTMLText field, you edit it in the backend using an HtmlEditorField (using TinyMCE) and display it in the template using a single tag (e.g. $Sidebarcontent) then it should work fine.
| 2284 Views | ||
| Go to Top | Next > |



