21490 Posts in 5783 Topics by 2622 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 662 Views |
-
Extending DataObject is this the best way?

14 September 2010 at 9:13pm
Hi, I am looking to create a homepage with feature. The feature will consist of 2 images and a little text. This is the code that I have so far, is kinda works but is there a better way of doing this?
thanks for any help guys, Ben
<?php
class Feature extends DataObject {
static $db = array(
'Slogan' => 'Varchar'
);
static $singular_name = 'Feature';
static $plural_name = 'Features';
static $has_one = array(
'Homepage' => 'Homepage',
'FeatureImage' => 'Image',
'FeatureText' => 'Image'
);
} -
Re: Extending DataObject is this the best way?

14 September 2010 at 9:39pm
Can't see anything wrong with that.
See this page for more info about DataObjects and DataObject Relation Mananagement:
http://doc.silverstripe.org/tutorial:5-dataobject-relationship-management
-
Re: Extending DataObject is this the best way?

15 September 2010 at 3:06am
I have it working fine in the backend although I cant seem to use the control in the template to loop through the slogans.
I have attached the 2 files I have been writing to see if I have dont anything wrong here.This is my control obviously with the test data but its not even looping first step:
<% control Slogans %>
<li style="background-image: url('{$ThemeDir}/images/media/feature-tv.png');">
<img src="{$ThemeDir}/images/media/we_make_the_web_beautifully_simple.png" width="" height="" alt="" />
</li>
<% end_control %>Thanks very much if any body can point me in the right direction.
-
Re: Extending DataObject is this the best way?

15 September 2010 at 3:25am
Hi Web2works
I notice you are using a HasManyCTF, which allows you to select which items to show or hide via checkboxes, only they will be off by default, so make sure you have checked the ones you want to show.
If you don't need that functonality, I would suggest just using a regular CTF, or even (way way) better is to use the DataObjectManager module and replace the CTF with DOM.
Aram
-------------------------------------------------------------------
www.SSBits.com - SilverStripe Tutorials, tips and other bits
-
Re: Extending DataObject is this the best way?

15 September 2010 at 3:32am
Thanks for that Aram, I will take a good read and play about with the DataObjectManager. I do love SilverStripe I just need to learn how to use it correctly. I bought the book but I have to had the time to read it page by page yet.
Thanks web2works
| 662 Views | ||
|
Page:
1
|
Go to Top |



