Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Custom Controls - Totally lost

Our old forums are still available as a read-only archive.

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

Page: 1 2 3
Go to End
Author Topic: 6072 Views
  • Jona
    Avatar
    Community Member
    19 Posts

    Re: Custom Controls - Totally lost Link to this post

    Hi willr,

    Sorry for the late response. My area was just recently hit by hurricane Ike and I haven't been able to get back to work on this.

    I think your most recent suggestion would work, except I am operating within a control called Menu(2) and no output is resulting from the $getlowerCaseTitle method. The method works outside of the control, but not inside it. Any ideas? I get an error when I try to extend Page instead of ContentController.

  • Jona
    Avatar
    Community Member
    19 Posts

    Re: Custom Controls - Totally lost Link to this post

    Willr,

    Thanks to your help, I have figured it out! I re-read your last reply and put it in the Page class that extends SiteTree. The function works fine here, as opposed to inside controller class. Perhaps this is what you and some others were referring to when you said applying the method to the "model" instead of the controller. Sorry, I would liked to have figured this out much sooner, but my unfamiliarity with the terminology of SilverStripe has caused me to misinterpret possibly a lot of what has been said.

    Thanks for all your help. The final code looks like this in case anyone else has a similar issue and doesn't understand by reading the English.

    /tutorial/code/Page.php

    <?php

    class Page extends SiteTree {
       static $db = array(
       );
       
       static $defaults = array(
       );
       function getlowerCaseTitle() {
       return strtolower($this->MenuTitle);
       }
    }

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

    /tutorial/templates/Page.ss

          <ul>
           <% control Menu(2) %>
             <li><a href="$Link" id="$getlowerCaseTitle">$MenuTitle</a></li>
        <% end_control %>
          </ul>

    6072 Views
Page: 1 2 3
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.