Jump to:

22999 Posts in 11854 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » [solved]can't get $sidebar to display in sidebar.ss, but it works in page.ss..

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

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

Page: 1
Go to End
Author Topic: 1033 Views
  • jolts
    Avatar
    Community Member
    3 Posts

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

    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.

    1033 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.