21309 Posts in 5738 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 627 Views |
-
how do i access fields i have created

1 November 2009 at 3:23am
I have created a VideoImage tab on my homepage.php like this
class HomePage extends Page {
static $db = array(
);
static $has_one = array(
'VideoImage' => 'Image',
'VideoTitle' => 'Text',
'VideoLink' => 'Text'
);function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.VideoImage', new ImageField('VideoImage'), 'Content');
$fields->addFieldToTab('Root.Content.VideoImage', new TextField('VideoTitle'), 'Content');
$fields->addFieldToTab('Root.Content.VideoImage', new TextField('VideoLink'), 'Content');return $fields;
}so I have a video image tab with VideoImage, VideoTitle, VideoLink
I can't seem to access these now on my HomePage.ss. I thought it would just be $VideoImage.URLSegment, $VideoTitle, $VideoLink but this does not pull in values.
I have tried $Content.VideoTitle too and does not work. Can anyone point me in right direction. I know must be basic.
-
Re: how do i access fields i have created

1 November 2009 at 6:25am
Hi zim!
I guess your error was in that $has_one array, which was not referencing DataObjects, but it’d be nice to explain the solution you found, for beginners.
Regards,
Juan -
Re: how do i access fields i have created

1 November 2009 at 6:53am
Hey dude i am more than happy to show the solution. i am new to this too and didn't want to look stupid
this is what I changed it too ... so yes it was the what you say i guess. i put them all onto the main tab in cms as well. it seems to work now so i can now upload a picture title and link and click off to say a youtube vid.. i am currently trying to then get this link to pop youtube link into nice light box.... am trying to use prettyphoto jquery plug in but not working yet.
class HomePage extends Page {
static $db = array(
'VideoTitle' => 'Text',
'VideoLink' => 'Text'
);
static $has_one = array(
'VideoImage' => 'Image'
);function getCMSFields() {
$fields = parent::getCMSFields();$fields->addFieldToTab('Root.Content.Main', new ImageField('VideoImage'));
$fields->addFieldToTab('Root.Content.Main', new TextField('VideoTitle'));
$fields->addFieldToTab('Root.Content.Main', new TextField('VideoLink'), 'Content');return $fields;
}then I can just accesss the fields like this
<a href="$VideoLink" rel="prettyPhoto"><img src="themes/tutorial/images/home/btn_video_play.png" alt="play"></a>
<a href="$VideoLink" rel="prettyPhoto">$VideoTitle</a>
<a href="$VideoLink" rel="prettyPhoto"><img src="$VideoImage.URL" alt="picture"></a>
| 627 Views | ||
|
Page:
1
|
Go to Top |

