<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>I'm Learning SilverStripe</title>
		<link>http://www.sslearn.info/sslearn/advance-users/</link>
		<atom:link href="http://www.sslearn.info/sslearn/advance-users/" rel="self" type="application/rss+xml" />
		<description></description>

		
		<item>
			<title>Creating a New Page Type</title>
			<link>http://www.sslearn.info/sslearn/creating-a-new-page-type/</link>
			<description>&lt;p&gt;The first time when we &lt;a href=&quot;http://www.sslearn.info/sslearn/how-to-install-silverstripe/&quot; title=&quot;How to Install Silverstripe&quot;&gt;install silverstripe&lt;/a&gt;, silverstripe has provided some type of standard pages that can we use. These page types are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Page&lt;/strong&gt;: this is the type of standard pages for each page shown.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ErrorPage&lt;/strong&gt;: This page is a page to display a customizable error conditions. For example we can use this type to create 404 pages (page not found) with a layout according to which we want.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;RedirectorPage&lt;/strong&gt;: This page is a page to redirect (move to another page), whether it is in our web or those outside of our web.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;VirtualPage&lt;/strong&gt;: same as Redirector page but only devoted to the existing pages on our website only, with different link from the destination page.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Apart from these four types of pages we can also create our own types of pages in accordance with our needs. Suppose we want to create a page whose content type consists of the title, date, pictures and content that we give the name of the type is &lt;strong&gt;ArticlePage&lt;/strong&gt;. The way is easy and it not takes a lot of time.&lt;/p&gt;
&lt;p&gt;Making a page type on silverstripe refer to the concept of &lt;a href=&quot;http://www.sslearn.info/sslearn/knowing-silverstripe-mvc/&quot; title=&quot;Knowing Silverstripe MVC&quot;&gt;MVC development framework&lt;/a&gt;. Where on this concept of a type of page is always going to have a component Model, View and Controller. For that, ArticlePage that will be created will have all three of these components.&lt;/p&gt;
&lt;h4&gt;Model and Controller&lt;/h4&gt;
&lt;p&gt;Model and Controller in silverstripe to a type of pages stored in a file that is located in the mysite/code/ directory&amp;nbsp; and have the extension .php. If we want to make a type named ArticlePage then we must create a php file named ArticlePage.php in that directory with the following contents:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;mysite/code/ArticlePage.php&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&amp;lt;?&lt;strong&gt;php&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;class&lt;/strong&gt; ArticlePage &lt;strong&gt;extends&lt;/strong&gt; Page { // Model&lt;br /&gt;    &lt;strong&gt;static&lt;/strong&gt; $db = array(&lt;br /&gt;       'Date' =&amp;gt; 'Date',&lt;br /&gt;    );&lt;br /&gt;    &lt;strong&gt;public&lt;/strong&gt; &lt;strong&gt;static&lt;/strong&gt; $has_one = array(&lt;br /&gt;        'Picture' =&amp;gt; 'Image',&lt;br /&gt;    );    &lt;br /&gt;    &lt;strong&gt;function&lt;/strong&gt; getCMSFields() {&lt;br /&gt;       $fields = parent::getCMSFields();&lt;br /&gt;    &lt;br /&gt;       $fields-&amp;gt;addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');&lt;br /&gt;       $fields-&amp;gt;addFieldToTab(&quot;Root.Content.Main&quot;, new ImageField('Picture'));&lt;br /&gt;            &lt;br /&gt;       &lt;strong&gt;return&lt;/strong&gt; $fields;&lt;br /&gt;    }    &lt;br /&gt;}&lt;br /&gt;/* controller */&lt;br /&gt;&lt;strong&gt;class&lt;/strong&gt; ArticlePage_Controller &lt;strong&gt;extends&lt;/strong&gt; Page_Controller {&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;The model and controller at silverstripe using Object-oriented programming concepts, where each page will have a hierarchy like the image below:&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;http://www.sslearn.info/sslearn/assets/Creating-a-new-Page-Type/_resampled/ResizedImage440255-Inheritance.png&quot; alt=&quot;Inheritance&quot; title=&quot;Inheritance&quot; width=&quot;440&quot; height=&quot;255&quot; /&gt;&lt;/p&gt;
&lt;p&gt;So that at each new page type for it must be the child of Page. In his own page type is already providing data fields in the form like titles and content, so that it automatically will also be included in each type of page that is derived from the type of this page. We just need to make two additional fields of date and pictures. So the controller file Articlepage we need to add a variable like:&lt;/p&gt;
&lt;pre&gt;    &lt;strong&gt;static&lt;/strong&gt; $db = array(&lt;br /&gt;       'Date' =&amp;gt; 'Date'&lt;br /&gt;    );&lt;br /&gt;    &lt;strong&gt;public static&lt;/strong&gt; $has_one = array(&lt;br /&gt;        'Picture' =&amp;gt; 'Image'&lt;br /&gt;    );    &lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;Static $db is a database variable that will be generated by silverstripe, the contents contain an array of fields. Here the static $db we added a Date field which the type of the field also named Date. If you want to add any other fields you can add yourself to the field names at $db variable with the type of data. List of other data types you can see on URL &lt;a href=&quot;http://doc.silverstripe.com/doku.php?id=data-types&quot; target=&quot;_blank&quot; title=&quot;Data-types&quot;&gt;http://doc.silverstripe.com/doku.php?id=data-types&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You may wonder why the $db variable is not directly include Picture with Image type? Actually the silverstripe image/file is stored using a separate table with the table of page. Because of that, if we want to use the image/file on our pages, we need relating our page to the table image/file. Here we use the $has_one variable which means every ArticlePage have one Picture with the type called Image.&lt;/p&gt;
&lt;p&gt;After declaring the field we must add these fields into the CMS form. GetCMSFields() method is the method to used to display the field in the CMS. For that we need to override this method to display the form accordance with the field that we have declare before.&lt;/p&gt;
&lt;h4&gt;The View&lt;/h4&gt;
&lt;p&gt;Furthermore, we must create a view of the ArticlePage pages. Make a file called ArticlePage.ss which is stored in the directory templates/ of our themes directory. The example content of the file may like this:&lt;/p&gt;
&lt;pre&gt;&amp;lt;html&amp;gt;&lt;br /&gt;    &amp;lt;head&amp;gt;&lt;br /&gt;        &amp;lt;title&amp;gt;Themes Silverstripe 1&amp;lt;/title&amp;gt;&lt;br /&gt;    &amp;lt;/head&amp;gt;&lt;br /&gt;    &amp;lt;body&amp;gt;&lt;br /&gt;    &amp;lt;ul&amp;gt;&lt;br /&gt;        &amp;lt;% control Menu(1) %&amp;gt;&lt;br /&gt;        &amp;lt;li&amp;gt;&amp;lt;a href=&quot;$Link&quot;&amp;gt;$MenuTitle&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;        &amp;lt;% end_control %&amp;gt;&lt;br /&gt;    &amp;lt;/ul&amp;gt;&lt;br /&gt;    &amp;lt;div&amp;gt;&lt;br /&gt;        &amp;lt;h1&amp;gt;$Title&amp;lt;/h1&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;Date : $Date.nice&amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;$Picture&amp;lt;/div&amp;gt;&lt;br /&gt;        $Content&lt;br /&gt;        $Form&lt;br /&gt;    &amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;If the Model, View and Controller is completed, access db/build/?flush=1 page in your browser. Later on the admin page will appear Article Page for the choice when making the page. The Article Page will show the form with the fields we have set.&lt;/p&gt;</description>
			<pubDate>Sat, 20 Mar 2010 00:53:24 -0500</pubDate>
			
			<guid>http://www.sslearn.info/sslearn/creating-a-new-page-type/</guid>
		</item>
		
		<item>
			<title>Creating Contact Page</title>
			<link>http://www.sslearn.info/sslearn/creating-contact-page/</link>
			<description>&lt;p&gt;At each web site, contact page (Contact Us) is one of the pages needed for site visitors to contact/comment to the creator's web. From the business side of this page must be made to accommodate the client desires. From this page also a business transaction can be starts.&lt;/p&gt;
&lt;p&gt;In silverstripe, we can create a contact page containing a form to be filled by the customer. Every customer who wants to contact or provide a message to the website must fill out a message on this form. Later messages are stored into the database or if it allows such messages will be immediately sent to the email the site creator. Page contact to be made in this post has a form that contains the field names, email, phone and message.&lt;/p&gt;
&lt;p&gt;Silverstripe has provide facilities page comments form, but is it a standard form. If we want another form we have to make our own. The way is easy and fast just like when we create pages in &lt;a href=&quot;http://www.sslearn.info/sslearn/creating-a-new-page-type/&quot;&gt;Creating New Page Type&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This time we will create a new page type called ContactPage in which there will be a form called ContactForm. For that we need to create a page that is ContactPage and ContactForm. And also there will be a data object used to store data-entry in database named Contact.&lt;/p&gt;
&lt;h4&gt;ContactForm&lt;/h4&gt;
&lt;p&gt;Create a file ContactForm.php in the directory&amp;nbsp; mysite/code/&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;mysite/code/ContactForm.php&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&amp;lt;? &lt;br /&gt;class ContactForm extends Form { &lt;br /&gt;&lt;br /&gt;function __construct($controller, $name) { &lt;br /&gt;   $fields = new FieldSet( &lt;br /&gt;      new TextField(&quot;name&quot;, &quot;Name&quot;), &lt;br /&gt;      new TextField(&quot;Phone&quot;, &quot;Phone&quot;), &lt;br /&gt;      new EmailField(&quot;email&quot;, &quot;E-mail&quot;), &lt;br /&gt;      new TextareaField (&quot;message&quot;,&quot;Message&quot;) &lt;br /&gt;   ); &lt;br /&gt;&lt;br /&gt;   $actions = new FieldSet(new FormAction(&quot;sendContact&quot;, &quot;Send&quot;)); &lt;br /&gt;   $validator = new RequiredFields(&quot;name&quot;, &quot;email&quot;, &quot;message&quot;); &lt;br /&gt;&lt;br /&gt;   parent::__construct($controller, $name, $fields, $actions, $validator); &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;function forTemplate() { &lt;br /&gt;   return $this-&amp;gt;renderWith(array( &lt;br /&gt;      $this-&amp;gt;class, &lt;br /&gt;      'Form' &lt;br /&gt;   )); &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;function sendContact($data, $form) { &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;} &lt;br /&gt;?&amp;gt; &lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;ContactForm is a class derived from Form. Where the content of the initial fields of the form that will be made. The file also contains the action of ContactForm if the form submitted. Action named sendContact on ContactForm created using the ContactForm Class method. In this case action is empty. This meant that we could customize the action later. &lt;br /&gt;&lt;br /&gt;View for ContactForm will have stored on themes/themes1/templates/Includes directory. For that we need to create a file in that directory ContactForm.ss.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;themes/sslearn/templates/Includes/ContactForm.ss &lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&amp;lt;% if IncludeFormTag %&amp;gt; &lt;br /&gt;    &amp;lt;form $FormAttributes&amp;gt; &lt;br /&gt;&amp;lt;% end_if %&amp;gt; &lt;br /&gt;&amp;lt;% if Message %&amp;gt; &lt;br /&gt;   &amp;lt;p id=&quot;{$FormName}_error&quot; class=&quot;error $MessageType&quot;&amp;gt;$Message&amp;lt;/p&amp;gt; &lt;br /&gt;&amp;lt;% else %&amp;gt; &lt;br /&gt;   &amp;lt;p id=&quot;{$FormName}_error&quot; class=&quot;message $MessageType&quot; style=&quot;display: none&quot;&amp;gt;&amp;lt;/p&amp;gt; &lt;br /&gt;&amp;lt;% end_if %&amp;gt; &lt;br /&gt;&lt;br /&gt;&amp;lt;fieldset class=&quot;form&quot;&amp;gt; &lt;br /&gt;   &amp;lt;legend&amp;gt;$Legend&amp;lt;/legend&amp;gt; &lt;br /&gt;   &amp;lt;% control Fields %&amp;gt; &lt;br /&gt;       &amp;lt;label&amp;gt;&amp;lt;span&amp;gt;$title&amp;lt;/span&amp;gt; $Field&amp;lt;/label&amp;gt; &lt;br /&gt;   &amp;lt;% end_control %&amp;gt; &lt;br /&gt;   &amp;lt;div class=&quot;clear&quot;&amp;gt;&amp;lt;!-- --&amp;gt;&amp;lt;/div&amp;gt; &lt;br /&gt;&amp;lt;/fieldset&amp;gt; &lt;br /&gt;&lt;br /&gt;&amp;lt;% if Actions %&amp;gt; &lt;br /&gt;   &amp;lt;div class=&quot;send&quot;&amp;gt; &lt;br /&gt;   &amp;lt;% control Actions %&amp;gt; &lt;br /&gt;      $Field &lt;br /&gt;   &amp;lt;% end_control %&amp;gt; &lt;br /&gt;   &amp;lt;/div&amp;gt; &lt;br /&gt;&amp;lt;% end_if %&amp;gt; &lt;br /&gt;&amp;lt;% if IncludeFormTag %&amp;gt; &lt;br /&gt;   &amp;lt;/form&amp;gt; &lt;br /&gt;&amp;lt;% end_if %&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;h4&gt;ContactPage&lt;/h4&gt;
&lt;p&gt;Create a file ContactPage.php in the directory&amp;nbsp; mysite/code/&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;mysite/code/ContactPage.php&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&amp;lt;?php &lt;br /&gt;&lt;br /&gt;class ContactPage extends Page{ &lt;br /&gt;   public function getCMSFields() { &lt;br /&gt;      $fields = parent::getCMSFields(); &lt;br /&gt;      $contactEntry = new TableListField(&quot;contactEntry&quot;, &quot;Contact&quot;, array(&quot;name&quot;=&amp;gt;&quot;Name&quot;, &quot;phone&quot;=&amp;gt;&quot;Phone&quot;, &quot;email&quot;=&amp;gt;&quot;Email&quot;,&quot;message&quot;=&amp;gt;&quot;Message&quot;)); &lt;br /&gt;      $fields-&amp;gt;addFieldToTab(&quot;Root.Content.Contact&quot;, $contactEntry); &lt;br /&gt;      return $fields; &lt;br /&gt;   } &lt;br /&gt;&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;class ContactPage_Controller extends Page_Controller { &lt;br /&gt;   function ContactForm(){ &lt;br /&gt;      if(Session::get('ContactFormEntry')) { &lt;br /&gt;         Session::clear('ContactFormEntry'); &lt;br /&gt;         return &quot;Your message has been sent&quot;; &lt;br /&gt;      } &lt;br /&gt;&lt;br /&gt;      $form = new ContactForm($this, &quot;ContactForm&quot;); &lt;br /&gt;      return $form; &lt;br /&gt;   } &lt;br /&gt;&lt;br /&gt;   function sendContact($data,$form) { &lt;br /&gt;      Session::set('ContactFormEntry', true); &lt;br /&gt;      $Contact = new Contact; &lt;br /&gt;      $form-&amp;gt;saveInto($Contact); &lt;br /&gt;      $Contact-&amp;gt;write(); &lt;br /&gt;      Director::redirectBack(); &lt;br /&gt;   } &lt;br /&gt;&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;ContactPage is a type of page that will be used to display ContactForm. ContactPage controller has a method to display ContactForm. From controller method, ContactPage also containing sendContact controller commands of the form. In sendContact method, data storage will be made into the data object Contact. For that we'll also have to create data objects Contact. Then after contact has been saved to database we can return to the previous page with instructions Director::redirectBack().&lt;/p&gt;
&lt;p&gt;In the file ContactPage.php we see the contents getCMSField method more or less as follows:&lt;/p&gt;
&lt;pre&gt;public function getCMSFields() { &lt;br /&gt;	$fields = parent::getCMSFields(); &lt;br /&gt;	$contactEntry = new TableListField(&quot;contactEntry&quot;, &quot;Contact&quot;, array(&quot;name&quot;=&amp;gt;&quot;Name&quot;, &quot;phone&quot;=&amp;gt;&quot;Phone&quot;, &quot;email&quot;=&amp;gt;&quot;Email&quot;,&quot;message&quot;=&amp;gt;&quot;Message&quot;)); &lt;br /&gt;	$fields-&amp;gt;addFieldToTab(&quot;Root.Content.Contact&quot;, $contactEntry); &lt;br /&gt;	return $fields; &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;In this method, we use an object TableListField to be used to display the contents of the Contact data objects that are used to store data from ContactForm entry.&lt;/p&gt;
&lt;p&gt;After creating the file we have to make ContactPage.php view the contents ContactPage.ss approximately as follows:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;themes/sslearn/templates/ContactPage.ss &lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&amp;lt;html&amp;gt; &lt;br /&gt;   &amp;lt;head&amp;gt; &lt;br /&gt;   &amp;lt;title&amp;gt;Themes Silverstripe 1&amp;lt;/title&amp;gt; &lt;br /&gt;   &amp;lt;/head&amp;gt; &lt;br /&gt;   &amp;lt;body&amp;gt; &lt;br /&gt;      &amp;lt;ul&amp;gt; &lt;br /&gt;      &amp;lt;% control Menu(1) %&amp;gt; &lt;br /&gt;         &amp;lt;li&amp;gt; &amp;lt;a href=&quot;$Link&quot;&amp;gt;$MenuTitle&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt; &lt;br /&gt;      &amp;lt;% end_control %&amp;gt; &lt;br /&gt;      &amp;lt;/ul&amp;gt; &lt;br /&gt;      &amp;lt;div&amp;gt; &lt;br /&gt;         &amp;lt;h1&amp;gt;$Title&amp;lt;/h1&amp;gt; &lt;br /&gt;         $Content &lt;br /&gt;         &lt;strong&gt;$ContactForm&lt;/strong&gt; &lt;br /&gt;      &amp;lt;/div&amp;gt; &lt;br /&gt;   &amp;lt;/body&amp;gt; &lt;br /&gt;&amp;lt;/html&amp;gt; &lt;br /&gt;&lt;/pre&gt;
&lt;h4&gt;Contact Data Object&lt;/h4&gt;
&lt;p&gt;Contact data object used to store data entry from ContactForm action. This data object that will represent the database. For making this Contact data object we need to make a contact.php file whose contents form a class named Contact derived from the DataObject class. These files are stored in the directory mysite / code / with following contents:&lt;/p&gt;
&lt;pre&gt;&amp;lt;?php &lt;br /&gt;&lt;br /&gt;class Contact extends DataObject{ &lt;br /&gt;&lt;br /&gt;	static $db = array( &lt;br /&gt;		'name' =&amp;gt; 'Varchar', &lt;br /&gt;		'phone' =&amp;gt; 'Varchar', &lt;br /&gt;		'email' =&amp;gt; 'Varchar', &lt;br /&gt;		'message' =&amp;gt; 'Text' &lt;br /&gt;	); &lt;br /&gt;&lt;br /&gt;} &lt;br /&gt;?&amp;gt; &lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;In the Contact class will have an array variable named $db. The contents of this variable is array containing field definition in the database that will be used to store data in the entry on ContactForm we have previously made. The name of his field-adjusted to the form that was created.&lt;/p&gt;
&lt;p&gt;The last stage before we use this contact form is to flush the database to build a database and silverstripe form and page design that we make. Way by typing ttp://localhost/sslearn/db/build/?flush=1 in your browser.&lt;/p&gt;
&lt;p&gt;Next ContactPage page type will appear in the combo box when we will add a new page in the admin page of our Silverstripe CMS.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;http://www.sslearn.info/sslearn/assets/Creating-Contact-Page/ContactPage.png&quot; alt=&quot;ContactPage&quot; title=&quot;ContactPage&quot; width=&quot;191&quot; height=&quot;191&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And also the contact tab will appear on the form on the contact page CMS to see anyone who has entry our contact data. This tab will contain the contact tablelistfield we have previously defined.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;http://www.sslearn.info/sslearn/assets/Creating-Contact-Page/ContactTab.png&quot; alt=&quot;ContactTab&quot; title=&quot;ContactTab&quot; width=&quot;480&quot; height=&quot;188&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The way is easy enough. Please try by yourself, if there is a problem please give comments.&lt;/p&gt;</description>
			<pubDate>Wed, 24 Mar 2010 00:58:51 -0500</pubDate>
			
			<guid>http://www.sslearn.info/sslearn/creating-contact-page/</guid>
		</item>
		
		<item>
			<title>Image Object on Silverstripe</title>
			<link>http://www.sslearn.info/sslearn/image-object-on-silverstripe/</link>
			<description>&lt;p&gt;If you read a post about &lt;a href=&quot;http://www.sslearn.info/sslearn/creating-a-new-page-type/&quot;&gt;Creating a New Page Type&lt;/a&gt;, I created a new type of pages that contain the image object. If we see inside of Class Articlepage there is a definition:&lt;/p&gt;
&lt;pre&gt;public static $has_one = array(&lt;br /&gt;	'Picture' =&amp;gt; 'Image'&lt;br /&gt;);&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;The meaning of the definition is each Articlepage will have a field of Image named Picture.&lt;/p&gt;
&lt;p&gt;Image is an object of silverstripe which is derived from the object file. All the attributes and methods contained in the object file will be owned by this object. The object image also has an additional method that is used to manipulate images for resizing.&lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;Inputing Image File&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;Image files can be input using a form object named ImageField. As ArticlePage.php there is one line of code in the method getCMSFields as follows:&lt;/p&gt;
&lt;pre&gt;$fields-&amp;gt;addFieldToTab(&quot;Root.Content.Main&quot;, new ImageField('Picture'));&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;The syntax above will display form fields to input the image file.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;http://www.sslearn.info/sslearn/assets/Image-Object-on-Silverstripe/_resampled/ResizedImage400151-ImageField.png&quot; alt=&quot;Image Field&quot; title=&quot;Image Field&quot; width=&quot;400&quot; height=&quot;151&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Each image file will be automatically uploaded to the directory assets/Uploads.&lt;/p&gt;
&lt;h4&gt;Image Object On the Templates&lt;/h4&gt;
&lt;p&gt;Image object also has a standard template that can be directly used in the template file (.ss). In the example template ArticlePage.ss, there is a code:&lt;/p&gt;
&lt;pre&gt;&amp;lt;div&amp;gt;$Picture&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;Where $Picture is Image Object, then on the HTML page will automatically become:&lt;/p&gt;
&lt;pre&gt;&amp;lt;img alt=&quot;engineeringrulerandpencil&quot; src=&quot;/sslearn/assets/Uploads/engineeringrulerandpencil.jpg&quot;&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;h4&gt;Resizing Image&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;SetWidth&lt;/strong&gt;(width)&lt;br /&gt;Is a method to set the width of the image. With this method the height of the image will be set proportionally.&lt;br /&gt;How to use:&lt;br /&gt;
&lt;pre&gt;&amp;lt;div&amp;gt;$Picture.SetWidth(50)&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SetHeight&lt;/strong&gt;(height)&lt;br /&gt;Is a method to set the height of the image. With this method the width of the image will be set proportionally.&lt;br /&gt;How to use:&lt;br /&gt;
&lt;pre&gt;&amp;lt;div&amp;gt;$Picture.SetHeight(50)&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SetSize&lt;/strong&gt;(width, height)&lt;br /&gt;Is a method to set the image size based on width and height specified. This method will adjust the image in a padded conditions, where the image will remain on for proportional, but if the height or width are disproportionately the image will be filled with a white background to make the size fixed.&lt;br /&gt;How to use:&lt;br /&gt;
&lt;pre&gt;&amp;lt;div&amp;gt;&lt;br /&gt;	&amp;lt;% control Picture %&amp;gt;&lt;br /&gt;		&amp;lt;% control SetSize(100,50) %&amp;gt;&lt;br /&gt;			&amp;lt;img src=&amp;rdquo;$URL&amp;rdquo;/&amp;gt;&lt;br /&gt;		&amp;lt;% end_control %&amp;gt;&lt;br /&gt;	&amp;lt;% end_control %&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt; &lt;br /&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Beside to the above method there is also another method that can be used in the object image. You can read the documentation referred to in &lt;a href=&quot;http://doc.silverstripe.org/doku.php?id=image&quot; target=&quot;_blank&quot;&gt;http://doc.silverstripe.org/doku.php?id=image&lt;/a&gt;.&lt;/p&gt;</description>
			<pubDate>Thu, 25 Mar 2010 21:15:26 -0500</pubDate>
			
			<guid>http://www.sslearn.info/sslearn/image-object-on-silverstripe/</guid>
		</item>
		
		<item>
			<title>Creating Flash Video Object on Silverstripe</title>
			<link>http://www.sslearn.info/sslearn/creating-flash-video-object-on-silverstripe/</link>
			<description>&lt;p&gt;One time ago, I was ever asked to do a web project in which there is a web page containing the video look like on youtube. The video file should be able to upload by their self. Later after the video uploaded, it have to be converted automatically to the .flv format which is will be displayed in the browser.&lt;/p&gt;
&lt;p&gt;Actually, there is extension provided by Silverstripe to manage video called &lt;a href=&quot;http://silverstripe.org/youtube-gallery-module/&quot; target=&quot;_blank&quot;&gt;Youtube Gallery&lt;/a&gt;. But this extension provides only features to take videos from youtube. While my client wants to manage their own videos without using youtube or other video sharing website. For that, I tried to make an object FlashVideo to accommodate a request from my client.&lt;/p&gt;
&lt;h4&gt;Requirements&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;1. FFMPEG&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;FFMPEG is an opensource application that can be used to record, convert and stream audio and video. FFMPEG application is required to be used to convert uploaded video results from the user. These applications can be downloaded for free from &lt;a href=&quot;http://ffmpeg.org/&quot; target=&quot;_blank&quot;&gt;http://ffmpeg.org/&lt;/a&gt;. If you use a hosting server, ask your admin to install this application.&lt;/p&gt;
&lt;p&gt;After downloading and installing on a computer that is used by silverstripe. You must know the path of ffmpeg binary file. If on my computer ffmpeg file is located in /usr/local/bin/ffmpeg. We must make sure ffmpeg run by running the command /usr/local/bin/ffmpeg on the console (microsoft windows in command prompt). Usually output looks like:&lt;/p&gt;
&lt;pre&gt;bash-3.2# /usr/local/bin/ffmpeg&lt;br /&gt;FFmpeg version SVN-r17910, Copyright (c) 2000-2009 Fabrice Bellard, et al.&lt;br /&gt;  configuration: --enable-libmp3lame --enable-shared --disable-mmx&lt;br /&gt;  libavutil     50. 0. 0 / 50. 0. 0&lt;br /&gt;  libavcodec    52.21. 0 / 52.21. 0&lt;br /&gt;  libavformat   52.31. 1 / 52.31. 1&lt;br /&gt;  libavdevice   52. 1. 0 / 52. 1. 0&lt;br /&gt;  libswscale     0. 7. 1 /  0. 7. 1&lt;br /&gt;  built on Mar 10 2009 22:33:58, gcc: 4.0.1 (Apple Inc. build 5465)&lt;br /&gt;At least one output file must be specified&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;If no error message means that ffmpeg is installed correctly.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. FLV Player&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We need a flv player to play the video on the web. In general, you can use any flv player. How to get it quite easily, search in google search engine with keywords &quot;flv player&quot; or &quot;flash video player&quot;. I myself use the JW Player which can be downloaded for free at &lt;a href=&quot;http://www.longtailvideo.com/players/jw-flv-player/&quot; target=&quot;_blank&quot;&gt;http://www.longtailvideo.com/players/jw-flv-player/&lt;/a&gt;. Flv player files will be .swf as a flash file.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;FlashVideo Object&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you've installed ffmpeg and download flv player then we are ready to begin making the FlashVideo object on Silverstripe.&lt;br /&gt;&lt;br /&gt;First of all, create a directory called FlashVideo in the main directory of silvertripe. Inside the FlashVideo directory, create two directories named code and swf, so the directory structure will look like in the picture below.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;http://www.sslearn.info/sslearn/assets/Creating-FlashVideo-Object-on-Silverstripe/Directory-Structure.png&quot; alt=&quot;Directory Structure&quot; title=&quot;Directory Structure&quot; width=&quot;257&quot; height=&quot;159&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The purpose of creating this directory is to separate the FlashVideo object and its components&amp;nbsp; from the main directory of our website (mysite) directory. However, we could actually make the object in the FlashVideo mysite directory, because its structure is same.&lt;/p&gt;
&lt;p&gt;After making FlashVideo directory, copy the .swf files of flv player that you have downloaded in the swf directory. Flash video player file&amp;nbsp; that I use is called player.swf, this file name will be used in viewing the FlashVideo file.&lt;/p&gt;
&lt;p&gt;Create a file called _config.php in FlashVideo/code/ directory&amp;nbsp; with the following contents:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;FlashVideo/_config.php&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&amp;lt;?&lt;strong&gt;php&lt;/strong&gt; &lt;br /&gt;	&lt;strong&gt;define&lt;/strong&gt;('FFMPEG_BIN',&quot;/usr/local/bin/ffmpeg&quot;);&lt;br /&gt;	$dir = &quot;video&quot;; &lt;br /&gt;&lt;br /&gt;	/*&lt;br /&gt;		Don't change these code bellow if you dont know what you're doing!!&lt;br /&gt;	*/&lt;br /&gt;	&lt;strong&gt;define&lt;/strong&gt;('VIDEO_PATH', ASSETS_PATH.&quot;/&quot;.$dir);&lt;br /&gt;	&lt;strong&gt;define&lt;/strong&gt;(&quot;VIDEO_DIR&quot;, ASSETS_DIR.&quot;/&quot;.$dir);&lt;br /&gt;&lt;br /&gt;	if (!file_exists(VIDEO_PATH)){&lt;br /&gt;		@mkdir(VIDEO_PATH);&lt;br /&gt;		@mkdir(VIDEO_PATH.&quot;/_resampled&quot;);&lt;br /&gt;		@mkdir(VIDEO_PATH.&quot;/_thumbnail&quot;);&lt;br /&gt;	}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;_config.php configuration File which will FlashVideo use later. Silverstripe MVC will read the _config.php file first before processing the other FlashVideo files in the directory. In this file there is constants named FFMPEG_BIN used to inform the location of the application binary FFMPEG file. Then there is the definition of $dir= &quot;videos&quot;, where $dir is the name of the directory to save the file processing results. This directory ($dir) will be located in the directory assets, so for our flv files can be managed easily through the &lt;strong&gt;Files &amp;amp; Images&lt;/strong&gt; on &lt;a href=&quot;http://www.sslearn.info/sslearn/silverstripe-admin-page-part-2/&quot;&gt;silverstripe admin page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;After creating the file _config.php, next is create a FlashVideo.php file that is placed on FlashVideo/code/ directory. The contents of FlashVideo.php are as follows:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;FlashVideo/code/FlashVideo.php&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&amp;lt;?php&lt;br /&gt;/* &lt;br /&gt;	Flash Video Model File for uploading Video Files and convert it to flv extension&lt;br /&gt;	By Firnas Nadirman	&lt;br /&gt;*/&lt;br /&gt;&lt;strong&gt;class&lt;/strong&gt; FlashVideo &lt;strong&gt;extends&lt;/strong&gt; File {&lt;br /&gt;&lt;br /&gt;	&lt;strong&gt;public static&lt;/strong&gt; $thumbnail_width = 114;&lt;br /&gt;&lt;br /&gt;	&lt;strong&gt;public static&lt;/strong&gt; $thumbnail_height = 87;&lt;br /&gt;&lt;br /&gt;	&lt;strong&gt;public static&lt;/strong&gt; $cms_thumbnail_width = 100;&lt;br /&gt;&lt;br /&gt;	&lt;strong&gt;public static&lt;/strong&gt; $cms_thumbnail_height = 60;&lt;br /&gt;	&lt;br /&gt;	&lt;strong&gt;public&lt;/strong&gt; $allowedExtensions = array(&quot;mov&quot;,&quot;mp4&quot;,&quot;avi&quot;,&quot;flv&quot;,&quot;mpeg&quot;,&quot;mpg&quot;);	&lt;br /&gt;	&lt;br /&gt;	&lt;strong&gt;public&lt;/strong&gt; $flvplayer = &quot;FlashVideo/swf/player.swf&quot;;&lt;br /&gt;		&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; getOriginalFileURL() {&lt;br /&gt;		return Director::baseURL() . $this-&amp;gt;FileName;&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; getURL() {&lt;br /&gt;		if (!file_exists($this-&amp;gt;getFlvFilePath())){&lt;br /&gt;			$this-&amp;gt;generateFlv();&lt;br /&gt;		}&lt;br /&gt;		&lt;br /&gt;		return Director::baseURL().$this-&amp;gt;getFlvFileName();&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; URL() {&lt;br /&gt;		return $this-&amp;gt;getURL();&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; forTemplate(){&lt;br /&gt;		if(!file_exists($this-&amp;gt;getCMSThumbFilePath())) {&lt;br /&gt;			$this-&amp;gt;getThumbnail($this-&amp;gt;stat(&quot;cms_thumbnail_width&quot;), $this-&amp;gt;stat(&quot;cms_thumbnail_height&quot;), $this-&amp;gt;getCMSThumbFilePath());&lt;br /&gt;		}&lt;br /&gt;		return &quot;&amp;lt;embed width=\&quot;400\&quot; height=\&quot;300\&quot; flashvars=\&quot;file=&quot;.$this-&amp;gt;getURL().&quot;&amp;amp;amp;image=&quot;.$this-&amp;gt;getCMSThumbFileName().&quot;\&quot; allowscriptaccess=\&quot;always\&quot; allowfullscreen=\&quot;true\&quot; quality=\&quot;high\&quot; bgcolor=\&quot;#FFFFFF\&quot; name=\&quot;player\&quot; id=\&quot;player\&quot; style=\&quot;\&quot; src=\&quot;$this-&amp;gt;flvplayer\&quot; type=\&quot;application/x-shockwave-flash\&quot;&amp;gt;&quot;;&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; getThumbFileName(){&lt;br /&gt;		return VIDEO_DIR.&quot;/_thumbnail/thumb_&quot;.strtolower($this-&amp;gt;Name).&quot;.png&quot;;&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; getThumbFilePath(){&lt;br /&gt;		return VIDEO_PATH.&quot;/_thumbnail/thumb_&quot;.strtolower($this-&amp;gt;Name).&quot;.png&quot;;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; getCMSThumbFileName(){&lt;br /&gt;		return VIDEO_DIR.&quot;/_thumbnail/CMSthumb_&quot;.strtolower($this-&amp;gt;Name).&quot;.png&quot;;&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; getCMSThumbFilePath(){&lt;br /&gt;		return VIDEO_PATH.&quot;/_thumbnail/CMSthumb_&quot;.strtolower($this-&amp;gt;Name).&quot;.png&quot;;&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	&lt;strong&gt;public function&lt;/strong&gt; CMSThumbnail() {&lt;br /&gt;		return $this-&amp;gt;generateCMSThumbnail();&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	&lt;strong&gt;public function&lt;/strong&gt; getImage() {&lt;br /&gt;		return $this-&amp;gt;generateThumbnail();&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; generateThumbnail(){&lt;br /&gt;		if(!file_exists($this-&amp;gt;getThumbFilePath())) {&lt;br /&gt;			$this-&amp;gt;getThumbnail($this-&amp;gt;stat(&quot;thumbnail_width&quot;), $this-&amp;gt;stat(&quot;thumbnail_height&quot;), $this-&amp;gt;getThumbFilePath());&lt;br /&gt;		}&lt;br /&gt;		return &quot;&amp;lt;img src=\&quot;&quot;.$this-&amp;gt;getThumbFileName().&quot;\&quot; title=\&quot;&quot;.$this-&amp;gt;Title.&quot;\&quot;&amp;gt;&quot;;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; generateCMSThumbnail() {&lt;br /&gt;		if(!file_exists($this-&amp;gt;getCMSThumbFilePath())) {&lt;br /&gt;			$this-&amp;gt;getThumbnail($this-&amp;gt;stat(&quot;cms_thumbnail_width&quot;), $this-&amp;gt;stat(&quot;cms_thumbnail_height&quot;), $this-&amp;gt;getCMSThumbFilePath());&lt;br /&gt;		}&lt;br /&gt;		&lt;br /&gt;		return &quot;&amp;lt;div style=\&quot;text-align:center;width: 100px;\&quot;&amp;gt;&amp;lt;a target=\&quot;_blank\&quot; href=\&quot;$this-&amp;gt;URL\&quot; title=\&quot;Download: $this-&amp;gt;URL\&quot;&amp;gt;&amp;lt;img src=\&quot;&quot;.$this-&amp;gt;getCMSThumbFileName().&quot;\&quot; alt=\&quot;&quot;.$this-&amp;gt;getCMSThumbFileName().&quot;\&quot; /&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;a style=\&quot;color: #0074C6;\&quot;target=\&quot;_blank\&quot; href=\&quot;$this-&amp;gt;URL\&quot; title=\&quot;Download: $this-&amp;gt;URL\&quot;&amp;gt;Download&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&quot;;&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; getThumbnail($width, $height, $filedest){&lt;br /&gt;		$videoFile = BASE_PATH.&quot;/&quot;.$this-&amp;gt;Filename;&lt;br /&gt;		if(file_exists($videoFile)){&lt;br /&gt;			$execthumb = FFMPEG_BIN.&quot; -i &quot;.$videoFile.&quot; -r 1 -s &quot;.$width.&quot;x&quot;.$height.&quot; -f image2pipe -vframes 1 -ss 00:00:01 &quot;.$filedest;&lt;br /&gt;			exec($execthumb);&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; getFlvFileName(){&lt;br /&gt;		return VIDEO_DIR.&quot;/_resampled/&quot;.&quot;flv_&quot;.strtolower($this-&amp;gt;Name).&quot;.flv&quot;;&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; getFlvFilePath(){&lt;br /&gt;		return VIDEO_PATH.&quot;/_resampled/flv_&quot;.strtolower($this-&amp;gt;Name).&quot;.flv&quot;;&lt;br /&gt;	}&lt;br /&gt;		&lt;br /&gt;	&lt;strong&gt;function&lt;/strong&gt; generateFlv(){&lt;br /&gt;		$videoFile = BASE_PATH.&quot;/&quot;.$this-&amp;gt;Filename;&lt;br /&gt;		$execvid =	FFMPEG_BIN.&quot; -i &quot;.$videoFile.&quot; -r 16 -ar 11025 -ab 32k -s cga -qscale 10 -y &quot;.$this-&amp;gt;getFlvFilePath();&lt;br /&gt;		exec($execvid);&lt;br /&gt;	}&lt;br /&gt;		&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;FlashVideo.php contains objects FlashVideo. This object is derived from the File object, so&amp;nbsp; this object has all the attributes and methods that are owned by the File object. In this FlashVideo object there are several variables used to configure the FlashVideo files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;$thumbnail_width&lt;/strong&gt;, this variable is used to determine the width of the thumbnail images of video.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$thumbnail_height&lt;/strong&gt;, this variable is used to determine the height of the thumbnail images of video.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$cms_thumbnail_width&lt;/strong&gt;, this variable is used to determine the width of the thumbnail images of video on the admin page.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$cms_thumbnail_width&lt;/strong&gt;, this variable is used to determine the height of the thumbnail image of video on the admin page.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$allowedExtensions&lt;/strong&gt;, this variable contains an array of file extension to be uploaded. You can add other file extensions on these variables.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$flvplayer&lt;/strong&gt;, this variable contains the relative path to the flv file player from silverstripe&amp;nbsp; directory.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you've made a second file, then run the command db/build/?flush=1 on silvertripe url to add FlashVideo objects into the silverstripe database structure. Later this object we can use on our pages.&lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;Using FlashVideo Object&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;To use the FlashVideo object on silverstripe page, we can add a fields type FlashVideo like adding fields of type Image. If in the &lt;a href=&quot;http://www.sslearn.info/sslearn/creating-a-new-page-type/&quot;&gt;previous post&lt;/a&gt; in ArticlePage.php, we can add the following code:&lt;/p&gt;
&lt;pre&gt;    &lt;strong&gt;public static&lt;/strong&gt; $has_one = array(&lt;br /&gt;	'Picture' =&amp;gt; 'Image',&lt;br /&gt;&lt;strong&gt;	'Video' =&amp;gt; 'FlashVideo'&lt;/strong&gt;&lt;br /&gt;    );&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;We can use FileIFrameField for uploading video files on getCMSFields() method.&lt;/p&gt;
&lt;pre&gt;    &lt;strong&gt;function&lt;/strong&gt; getCMSFields() {&lt;br /&gt;       $fields = parent::getCMSFields();&lt;br /&gt;    &lt;br /&gt;       $fields-&amp;gt;addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');&lt;br /&gt;       $fields-&amp;gt;addFieldToTab(&quot;Root.Content.Main&quot;, new ImageField('Picture'));&lt;br /&gt;      &lt;strong&gt; $fields-&amp;gt;addFieldToTab(&quot;Root.Content.Main&quot;, new FileIFrameField('Video'));&lt;/strong&gt;&lt;br /&gt;            &lt;br /&gt;       return $fields;&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;http://www.sslearn.info/sslearn/assets/Creating-FlashVideo-Object-on-Silverstripe/FlashVideo-Upload.png&quot; alt=&quot;FlashVideo Upload&quot; title=&quot;FlashVideo Upload&quot; width=&quot;573&quot; height=&quot;387&quot; /&gt;&lt;/p&gt;
&lt;p&gt;For our templates call variable of FlashVideo type ($Video) and placed on ArticlePage.ss as we want.&lt;/p&gt;
&lt;pre&gt;&amp;lt;h2&amp;gt;$Title&amp;lt;/h2&amp;gt;&lt;br /&gt;	&lt;br /&gt;$Picture&lt;br /&gt;&lt;strong&gt;$Video&lt;/strong&gt;&lt;br /&gt;$Content&lt;br /&gt;$Form&lt;br /&gt;$PageComments&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;Do not forget to do the command &lt;strong&gt;db/build/?flush=1&lt;/strong&gt;. After that will appear flv player on ArticlePage which will contain uploaded video.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;http://www.sslearn.info/sslearn/assets/Creating-FlashVideo-Object-on-Silverstripe/Page-With-Flv-Player.png&quot; alt=&quot;Page with Flv Player&quot; title=&quot;Page with Flv Player&quot; width=&quot;442&quot; height=&quot;542&quot; /&gt;&lt;/p&gt;
&lt;p&gt;You can download the source code files of the above FlashVideo objects &lt;a href=&quot;http://www.nanaz.net/images/upload/file/FlashVideo.zip&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;</description>
			<pubDate>Sun, 28 Mar 2010 06:48:44 -0500</pubDate>
			
			<guid>http://www.sslearn.info/sslearn/creating-flash-video-object-on-silverstripe/</guid>
		</item>
		

	</channel>
</rss>
