17488 Posts in 4473 Topics by 1978 members
| Go to End | ||
| Author | Topic: | 4873 Views |
-
Re: Sorting Articles

19 January 2008 at 6:18pm
> Thanks also for indirectly aswering one of my previous questions, how to access fields from
> php code.Can you elaborate a bit on this, because I seem to be missing where this was answered (I'm currently trying to implement something similar).
Thanks!
-
Re: Sorting Articles

19 January 2008 at 11:49pm
He wrote:
return DataObject::get("ArticlePage", "ParentID = {$this->ID}", "Created DESC", "", $limit);Where $this->ID is the ID field of the current row in the database, so you can access fields using $this->[your_fieldname_here] syntax.
For example, this is how my current LatestNews looks like:
function LatestNews($limit = null) {
if (null == $limit)
$limit = $this->Limit;
return DataObject::get("ArticlePage", "ParentID = {$this->ID}", "Created DESC", "", $limit);
}I have created an additional field named 'Limit' in the db to make the number of displayed ArticlePages configureable from the CMS, but still overrideable from the templates.
-
Re: Sorting Articles

20 January 2008 at 2:14pm
I see what you mean, thanks for following up on $this ;)
| 4873 Views | ||
| Go to Top |

