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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

[solved]can't get $sidebar to display in sidebar.ss, but it works in page.ss..


Go to End


2157 Views

Avatar
jolts

Community Member, 3 Posts

22 January 2009 at 8:41pm

Edited: 22/01/2009 11:37pm

hey all,

having an odd problem with my silverstripe 2.2.3 install trying to get the sidebar displayed in sidebar.ss

I've configured my page.php as instructed in the widgets tutorial, but if I add $Sidebar to sidebar.ss it refuses to display on the site.

I've tried db/build and ?flush-ing the mainpage, but nothing seems to work.

my page.php is standard..

<?php

class Page extends SiteTree {
	static $db = array(
	);
	static $has_one = array(
	"Sidebar" => "WidgetArea",
   );

function getCMSFields() {
	$fields = parent::getCMSFields();
	$fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("Sidebar"));
	return $fields;
	}
}



class Page_Controller extends ContentController {
	function init() {
		parent::init();
		
		Requirements::themedCSS("layout");
		Requirements::themedCSS("typography");
		Requirements::themedCSS("form");
	}
}

?>

and my sidebar.ss is also super basic, having only added the $Sidebar function to it.

<div id="Sidebar" class="typography">
  $Sidebar
	<div class="sidebarBox">
 		<h3>
			<% control Level(1) %>
				$Title
			<% end_control %>
  		</h3>
  		
  		<ul id="Menu2">
		  	<% control Menu(2) %>
  	    		<% if Children %>
			  	    <li class="$LinkingMode"><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levela"><span><em>$MenuTitle</em></span></a>
	  	    	<% else %>
		  			<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levela"><span><em>$MenuTitle</em></span></a>
				<% end_if %>	  
	  		
	  			<% if LinkOrSection = section %>
	  				<% if Children %>
						<ul class="sub">
							<li>
				 				<ul>
								 	<span class="roundWhite">
								  	<% control Children %>
						  	  			<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levelb"><span><em>$MenuTitle</em></span></a></li>
 				 					<% end_control %>
 				 					</span>
			 				 	</ul>
			 				 </li>
					  	</ul>
			 		 <% end_if %>
				<% end_if %> 
			</li> 
  			<% end_control %>
  		</ul>

		<div class="clear"></div>
		</div>

	<div class="sidebarBottom"></div>
$Sidebar

</div>
  

any help would be appreciated, since I feel like I'm banging my head against a wall here..

I'm running the install locally using vhosts, if that changes anything.

thanks a lot!

----edit-----

found the problem with some irc aid, ended up being the theme/template/layout/page.ss file.
there's an if statement that hides $sidebar if there are no child pages. so removing that fixed the thing. thank guise.