Jump to:

794 Posts in 409 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » Second widget on page fails

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 1262 Views
  • Friksel
    Avatar
    Community Member
    7 Posts

    Second widget on page fails Link to this post

    I use Silverstripe 3.0.3 stable release with the widgetmodule.
    I've created several widgets wich function properly when used on a page.
    But when I add several widgets to the same page the second widget fails.
    I found out the functions are not being called of the second widget or that the objects not exist.

    On this forum I also found this forum item:
    http://www.silverstripe.org/widgets-2/show/20989
    this seem to be the same problem.

    Next to puting 2 widgets into one widgetarea, I also tried putting 2 widgetareas (each with one widget).
    But that doesn't help.

    Is there any solution to this? I really need to be able to show 2 widgets on a page!!

    Hope you guys can help.

  • Nachos
    Avatar
    Community Member
    18 Posts

    Re: Second widget on page fails Link to this post

    Any luck with this problem? I'm having it too! I don't know exactly what you mean with the second widget - in my case it's the widget on the bottom of the widget space, that is the first that I add in the CMS. I can change the order, the one in the bottom won't show content.
    I'd also be glad to hear some advice - thanks!

  • Nachos
    Avatar
    Community Member
    18 Posts

    Re: Second widget on page fails Link to this post

    Respectfully and politely bumping this thread, since I was twice on the irc channel and nobody could help me out. Thanks!

  • Matty Balaam
    Avatar
    Community Member
    69 Posts

    Re: Second widget on page fails Link to this post

    I had the same problem, this was the solution for me: http://www.silverstripe.org/widgets-2/show/16123#post309314

    Let me know if that works for you.

  • Nachos
    Avatar
    Community Member
    18 Posts

    Re: Second widget on page fails Link to this post

    Thanks for the answer!

    I changed WidgetHolder.ss from /widgets/templates like this:

    <div class="WidgetHolder $ClassName<% if FirstLast %> $FirstLast<% end_if %>">
       <% if Title %><h3>$Title</h3><% end_if %>
       <div id="$ClassName">
    $Content
    </div>
    </div>


    Unfortunately still not working. I'm not using a blog theme, so that's the only WidgetHolder.ss I've got.

  • Matty Balaam
    Avatar
    Community Member
    69 Posts

    Re: Second widget on page fails Link to this post

    Are you double sure it is calling from that version of WidgetHolder.ss? Try adding in some test text to verify. A lot of widgets also come with their own WidgetHolder.ss file.

  • Nachos
    Avatar
    Community Member
    18 Posts

    Re: Second widget on page fails Link to this post

    You were right, it was using the blog theme although I renamed it like "theme_blogwashere". Weird.

    I succesfully added a text which I can see, but the second widget is still not showing content. Here's the code:

    <div class="BoxHeader">
    <% if Title %><h7>$Title</h7><% end_if %>
    </div>
    <div class="sidebarBox WidgetHolder $ClassName<% if FirstLast %> $FirstLast<% end_if %>">
       <p>This is a Test</p>
    <div id="$ClassName">
    $Content
    </div>
       <div class="clear"><!-- --></div>
    </div>
    <div class="sidebarBottom"><!-- --></div>

    Am I doing something wrong?
    Thank you so much for your help!

  • DanielB
    Avatar
    Community Member
    5 Posts

    Re: Second widget on page fails Link to this post

    I had the same problem, my widget would display fine as the first widget but as soon as I moved it to the second or third etc widget on the page it would not display.

    My template was not finding the method it was calling, "public function LatestProjects()" in the "class LatestProjectsWidget extends Widget" class.

    I was able to fix this by extending widget_controller and putting the function in there.

    class LatestProjectsWidget_Controller extends Widget_Controller {
       
       public function LatestProjects() {
          $projects = CaseStudy::get()->sort('Created', 'Desc')->limit($this->Limit);
          return ($projects) ? $projects : false;
       }
    }

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