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

Second widget on page fails


Reply


8 Posts   1404 Views

Avatar
Friksel

Community Member, 7 Posts

20 December 2012 at 4:25am

Edited: 20/12/2012 4:27am

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.

Avatar
Nachos

Community Member, 21 Posts

8 May 2013 at 11:51am

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!

Avatar
Nachos

Community Member, 21 Posts

21 May 2013 at 8:35am

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

Avatar
Matty Balaam

Community Member, 69 Posts

22 May 2013 at 1:12am

Edited: 22/05/2013 1:12am

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.

Avatar
Nachos

Community Member, 21 Posts

22 May 2013 at 3:26am

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.

Avatar
Matty Balaam

Community Member, 69 Posts

22 May 2013 at 7:42am

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.

Avatar
Nachos

Community Member, 21 Posts

22 May 2013 at 8:02am

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!

Avatar
DanielB

Community Member, 5 Posts

27 May 2013 at 7:31pm

Edited: 27/05/2013 7:32pm

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;
   }
}