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.

Template Questions /

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

basic boolean function creation - newbie

Go to End

2 Posts   1786 Views


Community Member, 24 Posts

13 August 2009 at 3:30am

Edited: 13/08/2009 3:31am

Got a newbie question,
as am SS and php beginer somehow cant get this function to work.


class GalleryPage extends Page
	static $has_many = array (
		'GalleryImages' => 'GalleryImage'
	public function getCMSFields()
		$f = parent::getCMSFields();
		$manager = new FileDataObjectManager(
			$this, // Controller
			'GalleryImages', // Source name
			'GalleryImage', // Source class
			'Resource', // File name on DataObject
				//'Thumbnail' => 'Image',
				'Name' => 'Name',
				'Caption' => 'Caption'
			), // Headings 
			'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
			// Filter clause
			// Sort clause
			// Join clause
        $f->addFieldToTab("Root.Content.Main", $manager, "Content_Caption");
		return $f;

class GalleryPage_Controller extends Page_Controller {	
		public function IsFLV()			
		$res = $this->Resource;
		$ext = $res->getExtension();
			if ($ext == 'flv') 
				return true;			
				return false;

what i want to do is to get the Resource(is a file) extension, find out if it is and flv and return boolean.
i know the above syntax isnt right, but cant figure out how it should be.
tried different ways, mostly the $res is empty, or the page wont load at all.



Community Member, 712 Posts

14 August 2009 at 8:53am

GalleryPage doesn't have a "Resource" object, so $this->Resource will not return anything.

What are you trying to do?

I see that GalleryPage has many associated GalleryImages - is this what you are looking at? If so, you need to decide which GalleyImage you want to test, since it is not a 'one - one' relationship.