<?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>Forum posts to 'Archive'</title>
		<link>http://www.silverstripe.org/archive/rss</link>
		<atom:link href="http://www.silverstripe.org/archive/rss" rel="self" type="application/rss+xml" />
		<description></description>

		
		<item>
			<title>Need help with homepage function</title>
			<link>http://www.silverstripe.org/archive/show/80276#post80276</link>
			<description>&lt;p&gt;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!&lt;/p&gt;&lt;p&gt;I've got a DocumentHolder type and a DocumentPage type:&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;codesnippet&quot;&gt;&lt;p&gt;*** in DocumentHolder.php ***&lt;/p&gt;&lt;p&gt;class DocumentHolder extends Page {&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;static $db = array();&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;static $has_one = array();   &lt;br /&gt;        static $allowed_children = array('DocumentPage');  &lt;br /&gt;}&lt;/p&gt;&lt;p&gt;class DocumentHolder_Controller extends Page_Controller {}&lt;/p&gt;&lt;p&gt;*** in DocumentPage.php ***&lt;/p&gt;&lt;p&gt;class DocumentPage extends Page {&lt;br /&gt;   static $db = array(&lt;br /&gt;   'PDFdocDesc' =&amp;gt; 'Text',&lt;br /&gt;   'ShowOnHomePage' =&amp;gt; 'Text'&lt;br /&gt;   );&lt;br /&gt;   static $has_one = array(&lt;br /&gt;      'PDFdoc' =&amp;gt; 'File'&lt;br /&gt;   );&lt;br /&gt;   &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;   function getCMSFields() {&lt;br /&gt;      &amp;nbsp;&amp;nbsp;&amp;nbsp;$fields = parent::getCMSFields();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$fields-&amp;gt;addFieldToTab(&quot;Root.Content.Main&quot;, new TextField('PDFdocDesc',&quot;Document Description&quot;));&lt;br /&gt;      &amp;nbsp;&amp;nbsp;&amp;nbsp;$fields-&amp;gt;addFieldToTab(&quot;Root.Content.Main&quot;, new FileIFrameField('PDFdoc',&quot;PDF Document&quot;)); &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$fields-&amp;gt;addFieldToTab(&quot;Root.Content.Main&quot;, new CheckboxField('ShowOnHomePage',&quot;Show this on homepage?&quot;)); &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$fields-&amp;gt;removeFieldFromTab(&quot;Root.Content.Main&quot;, &quot;Content&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;      return $fields;&lt;br /&gt;   }&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;class DocumentPage_Controller extends Page_Controller {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;}&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;p&gt;and, I'm pretty sure this is where I'm getting trouble because I just copied the news one &amp;amp; I don't fully understand it yet  &lt;img src='http://www.silverstripe.org/sapphire/images/smilies/smile.gif'&gt; &lt;/p&gt;&lt;p&gt;&lt;div class=&quot;codesnippet&quot;&gt;&lt;p&gt;class HomePage_Controller extends ContentController {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;function init() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent::init();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;function LatestNews($num=5) {&lt;br /&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp;$news = DataObject::get_one(&quot;NewsIntroPage&quot;);&lt;br /&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp;return ($news) ? DataObject::get(&quot;NewsArticlePage&quot;, &quot;ParentID = $news-&amp;gt;ID&quot;, &quot;Date DESC&quot;, &quot;&quot;, $num) : false;&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;function HomeDocs($num=5) {&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; $doccys = DataObject::get_one(&quot;DocumentHolder&quot;);&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; return ($doccys) ? DataObject::get(&quot;DocumentPage&quot;, &quot;ParentID = $doccys-&amp;gt;ID&quot;, &quot;Date DESC&quot;, &quot;&quot;, $num) : false;&lt;br /&gt;}&lt;br /&gt;}&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;p&gt;In my sidebar I'm trying to do this:&lt;br /&gt;&lt;div class=&quot;codesnippet&quot;&gt;&lt;p&gt;&amp;lt;% control HomeDocs %&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;% if $ShowOnHomePage %&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;    &amp;lt;li &amp;gt;&amp;lt;a href=&quot;$PDFdoc.filename&quot; target=&quot;_blank&quot; title=&quot;Download this file&quot;&amp;gt;$Title t&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;% end_if %&amp;gt;&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;% end_control %&amp;gt;&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;p&gt;any help with this would be much appreciated. Thanks&lt;/p&gt;&lt;br&gt;&lt;br&gt;Posted to: Need help with homepage function &lt;a href=&quot;http://www.silverstripe.org/archive/show/80276#post80276&quot;&gt;Show Thread&lt;/a&gt; | &lt;a href=&quot;http://www.silverstripe.org/archive/show/80276#post80276&quot;&gt;Post Reply&lt;/a&gt;</description>
			<pubDate>Fri, 30 May 2008 21:48:44 +1200</pubDate>
			<dc:creator>NickJacobs</dc:creator>
			<guid>http://www.silverstripe.org/archive/show/80276#post80276</guid>
		</item>
		

	</channel>
</rss>