Jump to:

796 Posts in 409 Topics by 304 members


SilverStripe Forums » Widgets » Problems creating a simple widget

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 583 Views
  • nw
    Community Member
    3 Posts

    Problems creating a simple widget Link to this post

    [Update] I think I've got it working now. It seems that having:

    class MyWidget_Controller extends Widget_Controller {
       function WidgetHolder() {
             return $this->renderWith("WidgetHolder");

    in the widgets PHP code makes everything work. I'm still not sure if that's the right way to do things, but it works.

    Hi, I'm trying to make a fairly simple widget, but having some trouble. The main thing I want to achieve is for a piece of html to be outputted (so that an iframe is displayed within the widget area), with this snippet containing a username entered by the site admin.
    i.e. something like <iframe src="example.com/username/pages"></iframe> should be the outputted source of the widget, with the username portion having been entered in the widget tab by an admin.

    However, I'm having some trouble (I'm fairly new to Silverstripe and PHP): I managed to get the basic widget structure running fine, but I'm stuck on how to output the html snippet from the widget's php file to its ss file. Looking at similar (but older) widgets, it seems like this would be done something like:

       function iframeOut() {
          $output = '<iframe src="http://www.example.com/' . $UserName . '/pages"></iframe>';
       return $output;

    and then in the widget ss file, simply have $iframeOut to include the iframe HTML snippet. The problem is, this isn't working for me (absolutely nothing is included in place of the $iframeOut in the .ss file). Any suggestions as to what I'm doing wrong would be greatly appreciated!

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.