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.

Widgets /

Discuss SilverStripe Widgets.

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

Again "Bad widget class name given"


Reply


2 Posts   1560 Views

Avatar
Michel

Community Member, 2 Posts

18 December 2008 at 12:24pm

Edited: 18/12/2008 12:27pm

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.

Avatar
pecos_red

Community Member, 7 Posts

27 January 2009 at 7:22pm

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.