Jump to:

23364 Posts in 18142 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Need some help with additional menu

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: 768 Views
  • panton
    Avatar
    Community Member
    4 Posts

    Need some help with additional menu Link to this post

    Hi there,
    I am desperately trying to get an independent menu on my webpage to work.

    Referring to this post:
    http://www.silverstripe.org/general-questions/show/5822
    I implemented the following in the mysite/code/Page.php:

    class Page_Controller extends ContentController {

    function Menu3(){
    $whereStatement = "ShowInTopMenu = 1";
    return DataObject::get("Page", $whereStatement);
    }

    And in the navigation.ss I have written:

    <ul>
    <% control Menu3 %>
    <li class="$FirstLast $LinkingMode">
    <a href="$Link" title="$Title.XML"><span>$MenuTitle.XML</span></a></li>
    <% end_control %></ul>

    All I get is:

    Server error
    Sorry, there was a problem with handling your request.

    What am I doing wrong?

    Any hint would be really appreciated.

  • bartvanirsel
    Avatar
    Community Member
    94 Posts

    Re: Need some help with additional menu Link to this post

    Hi,

    What's the error message when you run your site in dev mode?

  • panton
    Avatar
    Community Member
    4 Posts

    Re: Need some help with additional menu Link to this post

    Hi, it says:
    [User Error] Couldn't run query: SELECT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", (...)
    AND (ShowInTopMenu = 1) ORDER BY "Sort" Unknown column 'ShowInTopMenu' in 'where clause'

    I have no idea what that means.

  • bartvanirsel
    Avatar
    Community Member
    94 Posts

    Re: Need some help with additional menu Link to this post

    Seems like you did not run dev/build did you define ShowInTopMenu in your model?

  • panton
    Avatar
    Community Member
    4 Posts

    Re: Need some help with additional menu Link to this post

    Ah ok, thank you.
    All I have done so far are the to things written above. Sorry for the stupid question, but how and where do I have to define it?

    I have run run dev/build, but with no effect.

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Need some help with additional menu Link to this post

    Did you ever create the ShowInTopMenu field? Only then does /dev/build/?flush=1 actually create the field in the database. The following example adds a new checkbox to the Behaviour tab on each page in the CMS, where you can then check the pages you want in the topmenu...

    It comes from the recipe in the link you'll find in the topic you got your example from...

    class Page extends SiteTree {
       static $db = array(
          "ShowInTopMenu" => "Boolean"
       );

       function getCMSFields() {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab("Root.Behaviour", new CheckboxField("ShowInTopMenu", "Show special menu "));
          return $fields;
       }
       ...

  • panton
    Avatar
    Community Member
    4 Posts

    Re: Need some help with additional menu Link to this post

    Martimiz--thank you for opening my eyes!

    768 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.