Hi,
IT WORKED!!! Again, thank you very much, here is what I've changed:
mysite/code/Page.php (add only this part):
[...]
class Page_Controller extends ContentController {
[...]
function HasWidgets()
{
if($this->SidebarID)
{
return DataObject::get("Widget", "ParentID = $this->SidebarID");
}
return false;
}
}
--------------------------------------------------------------------------------------------
themes/[YOUR_THEME_NAME]/templates/Layout/Page.ss (the whole file):
<div class="typography">
<% if HasWidgets %>
<div id="Widgetbar" class="typography">
$Sidebar
</div>
<% end_if %>
<% if Menu(2) %>
<% include SideBar %>
<% end_if %>
<% if HasWidgets %>
<div id="Content">
<% else %>
<% if Menu(2) %>
<div id="Content">
<% end_if %>
<% end_if %>
<% if Level(2) %>
<% include BreadCrumbs %>
<% end_if %>
<h2>$Title</h2>
$Content
$Form
$PageComments
<% if HasWidgets %>
</div>
<% else %>
<% if Menu(2) %>
</div>
<% end_if %>
<% end_if %>
</div>
--------------------------------------------------------------------------------------------
themes/[YOUR_THEME_NAME]/css/layout.css (only make these changes):
These changes are depending to your theme, I changed it, because the originally Sidebar is on the left in my theme and I wanted to have the widgets on the right, so I copied the complete style information for the Sidebar and changed every css ID from Sidebar into Widgetbar and changed the float from left to right.
If you want to use the same css layout for the Widgetbar as the Sidebar is, then change the following the the mentioned file (the file you should have changed before):
themes/[YOUR_THEME_NAME]/templates/Layout/Page.ss (change only this part):
<div class="typography">
<% if HasWidgets %>
<div id="Sidebar" class="typography"> <--- id changed from Widgetbar into Sidebar
$Sidebar
</div>
[...]
I hope this helps not only me.
Thanks everybody for their advices!
If anyone have problems with these changes, please fell free to ask.
Kind regards,
Fabi
(I've changed to topic from "Check if site has widget", because this is not a very good title to find this thread, when you're searching for how to add widgets in the every site.)