21309 Posts in 5738 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 765 Views |
-
How to fill my sidebar?

3 May 2010 at 5:09am
On my website is a sidebar where I want to show some related informations, related pages, internal promotions etc.
At first I thought I'll create a new tab and some text-inputs in the back-end to write all these (it's a pretty cool feature in SS
. But as I've seen there are about 15-20 "snippets" I want to use and they repeat on other pages I think it isn't the best way to write the same more than once.
Is there a nice and cool way in SS I can fill my sidebar? Can you please give me some insights and share experience? That would be great!
-
Re: How to fill my sidebar?

5 May 2010 at 1:14pm Last edited: 5 May 2010 1:15pm
From what I understand, you want one unique sidebar that you can edit in the cms and display on multiple pages?
What I would do is create a new page in the root of the website called 'Sidebar'.
Make this page hidden from the menu and search.
In the content put what you want in the sidebar.
Then in the page templates, where you want the side bar to go you call the following:<% control Page(sidebar) %>
$Content
<% end_control %> -
Re: How to fill my sidebar?

24 May 2010 at 1:55am
Hi ampedup.
Yes, I want a unique sidebar but not only one but for different sections different sidebars (content).I followed an example (German SS Forum http://www.silverstripes.de/mvc-coding/show/130?showPost=1434) but can not complete it.
What I have:
There is a new SiteTree select field above my 'content' in the back-end where I can select a page. But when I click save my selection gets lost, it seems SS can't save it in the DB, although there is no error.The Code: (mysite/code/Page.php)
class Page extends SiteTree {
static $db = array(
);
static $has_one = array(
'Hintergrundbild' => 'Image',
'Sidebar' => 'Page'
);// Verbindung Hintergrundbild zur Bild-Datenbank
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Hintergrundbild", new ImageField('Hintergrundbild'));
$fields->addFieldToTab('Root.Content.Main', new TreeDropdownField("Sidebar", "Sidebar anzeigen", "SiteTree"), 'Content');
return $fields;
}
}Code 2: (mysite/code/Sidebar.php)
<?php
class Sidebar extends Page {
static $db = array();
static $has_one = array();
}class Sidebar_Controller extends Page_Controller {
}
?>
Code 3: (themes/n1/templates/Page.ss)
<p>Start Sidebar</p>
<% control Sidebar %>
<div id="contentright">
sidebar Content: $Content
</div>
<% end_control %>
| 765 Views | ||
|
Page:
1
|
Go to Top |


