Jump to:

794 Posts in 409 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » Again "Bad widget class name given"

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 1484 Views
  • Michel
    Avatar
    Community Member
    2 Posts

    Again "Bad widget class name given" Link to this post

    Hello everybody.

    Must Say Like the new styling. But not here to comment on that.
    I'm designing a site with SilverStripe. Been busy for ages but just learning SS and PHP.
    It's a bit different from plain HTML. But almost finished my first site.

    Solved all I encountered except the part of the Widgets. Can't seem to get it working.
    And I have no clue anymore.

    Followed the instructions and changed the /mysite/code/Page.PHP as below

    <?php

    class Page extends SiteTree {
       
       public static $db = array(
       );
       
       public static $has_one = array(
       "SideBar" => "WidgetArea",
       );
       
       function getCMSFields() {
       $fields = parent::getCMSFields();
       $fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("SideBar"));
       return $fields;
    }
    *******

    Also changed in Themes/mytheme/template/includes/SideBar.ss
    The last lines to include the Widgets in the sidebar like this

       <div class="clear"></div>
       </div>
       <div class="sidebarBottom">
    $SideBar
       </div>
    </div>
    ********

    Finally I like to mention that I changed the /templates/Layout/page.ss
    to include the side bar at any given moment and not just when a menu is present. I did this by removing the "If" statement like this

    <div class="typography">
       
          <% include SideBar %>
          <div id="Content">
       
             
       <% if Level(2) %>
           <% include BreadCrumbs %>
       <% end_if %>
       
             
          $Content
          $Form
          $PageComments
          
       
       <% if Menu(2) %>
          </div>
       <% end_if %>
    </div>

    **********

    That is all I did and I included several widget's but in the CMS the installed Widgets all give the error of "Bad widget class name given". While the Blog Widgets do seem to Work.

    I'm developing directly on the server so but with the Blog Widgets working I still have no clue what is not working. I am a Newbe so please let any comment given be at my level of understanding. But than again any reaction is welcome.

  • pecos_red
    Avatar
    Community Member
    7 Posts

    Re: Again "Bad widget class name given" Link to this post

    public static $has_one = array(
    "SideBar" => "WidgetArea",
    );

    I think the comma needs to be removed after "Widget Area".

    For me the widgets still didn't work until I added the archive widget to the widget area first.

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