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

Multiple Themes For Widgets


Reply


2 Posts   641 Views

Avatar
mrsteveheyes

Community Member, 15 Posts

29 June 2011 at 11:22pm

Edited: 29/06/2011 11:25pm

Hi there,

I'm new to Silverstripe but am loving it so far. I have created a widget for pulling in Social Media which is working great. But I am working on a site which has a twitter feed and a facebook feed. Both have different HTML and CSS.

So I was wondering if I can dictate which theme the Widget should use rather than just using the default one?

Hope that makes sense.

[bold]Edit[/bold]

For more context here is the function I'm using the Page Controller to render the Twitter feed:

public function TwitterStream() {
   $widget = new SocialPulseWidget();
   $widget->WidgetTitle = 'Our Tweets';
   $widget->addFeed('twitter', array('name' => 'prbloke', 'links' => true));
var_dump($widget);die();
   return $widget->renderWith('WidgetHolder');
}

Avatar
mrsteveheyes

Community Member, 15 Posts

30 June 2011 at 1:29am

Actually! I figured out how to do it!

You can create a tempalte file in /themes/{theme_name}/templates/layout and call it in renderWith.

So for example: I have create a TwitterStream.ss file in the right folder and now I just use:

return $widget->renderWith('TwitterStream');

Win!