Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverstripe 3 - Why is data not being passed to the template
    primarykey
    data
    text
    <p>I'm trying to use the YouTube widget but it appears that there are issues with it in Silverstripe 3 and it is not passing the DataObjectSet to the template and as a result, I cannot pass my data to the template. All the values are displayed correctly in the CMS, it is only in the template that they are not passed so it appears to be an issue with DataObjectSet in SS3. I've searched pretty extensively but cannot find any mentions of it's deprecation in SS3.</p> <pre><code>class YoutubeWidget extends Widget{ static $title = "My favorite video"; static $cmsTitle = "Your tube widget"; static $description = "This widget can embed clips from youtube.com"; static $db = array( "Width" =&gt; "Int", "Height" =&gt; "Int", "URL" =&gt; "Text", "Title" =&gt; "Text" ); static $defaults = array( "Width" =&gt; 283, "Height" =&gt; 182 ); function getCMSFields(){ return new FieldList( new NumericField("Width", "Video Width"), new NumericField("Height", "Video Height"), new TextField("URL", "Video URL"), new TextField("Title","Title or a note about this video") ); } function GetVideoData(){ $output = new DataObjectSet(); $output-&gt;push( new ArrayData( array( "Width" =&gt; $this-&gt;Width, "Height" =&gt; $this-&gt;Height, "URL" =&gt; $this-&gt;URL, "Title" =&gt; $this-&gt;Title ) ) ); return $output; } } </code></pre> <p>None of the variables are being populated in the template.</p> <pre><code>&lt;% control GetVideoData %&gt; &lt;object width="$Width" height="$Height"&gt; &lt;param name="movie" value="$URL"&gt;&lt;/param&gt; &lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt; &lt;embed src="$URL" type="application/x-shockwave-flash" allowfullscreen="true" width="$Width" height="$Height"&gt;&lt;/embed&gt; &lt;/object&gt; &lt;p style="text-align:center;"&gt;$Title&lt;/p&gt; &lt;% end_control %&gt; </code></pre> <p>If I wrap the control in &lt;% if GetVideoData %> it doesn't access the control, indicating that nothing is being returned, this also happens even if I change the GetVideoData function to simply return a string. ie <code>return "asdf";</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload