10689 Posts in 2796 Topics by 1518 members
Jump to:If this is your first visit, you will need to register before you can post. However, you can browse all messages below.
| Page: 1 | go to end | Reply | |
| Author | Topic: Need help with homepage function | 221 views |

30 May 2008 at 9:48pm
Hi, I'm pretty new to this and having some trouble implementing a function on the homepage which lists pages from another section. I've got the news list sorted from the tutorials but can't seem to replicate it ... and trying to find documentation is a nightmare!
I've got a DocumentHolder type and a DocumentPage type:
class DocumentHolder extends Page {
static $db = array();
static $has_one = array();
static $allowed_children = array('DocumentPage');
}
class DocumentHolder_Controller extends Page_Controller {}
*** in DocumentPage.php ***
class DocumentPage extends Page {
static $db = array(
'PDFdocDesc' => 'Text',
'ShowOnHomePage' => 'Text'
);
static $has_one = array(
'PDFdoc' => 'File'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new TextField('PDFdocDesc',"Document Description"));
$fields->addFieldToTab("Root.Content.Main", new FileIFrameField('PDFdoc',"PDF Document"));
$fields->addFieldToTab("Root.Content.Main", new CheckboxField('ShowOnHomePage',"Show this on homepage?"));
$fields->removeFieldFromTab("Root.Content.Main", "Content");
return $fields;
}
}
class DocumentPage_Controller extends Page_Controller {
}
and, I'm pretty sure this is where I'm getting trouble because I just copied the news one & I don't fully understand it yet :)
function HomeDocs($num=5) {
$doccys = DataObject::get_one("DocumentHolder");
return ($doccys) ? DataObject::get("DocumentPage", "ParentID = $doccys->ID", "Date DESC", "", $num) : false;
}
}
In my sidebar I'm trying to do this:
any help with this would be much appreciated. Thanks
Last edited: 30 May 2008 at 9:52pm
| 221 views | |||
| go to top | Reply |