17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1606 Views |
-
Latest article from diferent article holders?

21 October 2008 at 1:39am
Example site look:
Start
-first category
--1subcatergory (article holder)
--2subcategrory (article holder)
--3subcategory (article holder)
-second category
--1subcatergory (article holder)
--2subcategrory (article holder)
--3subcategory (article holder)
...
My problem is how to show in 1category or 2category latest articles (ArticlePage) from their (only their) subcategories? -
Re: Latest article from diferent article holders?

21 October 2008 at 10:05am
Hi
You could simply use something like this in your template:
<% control Children.First %>
... output something, eg. $Title
<% end_control %>This will output the first Child of the current page. The last one could be accessed with Children.Last
-
Re: Latest article from diferent article holders?

21 October 2008 at 12:06pm
i was thinking about some sort of function like in http://doc.silverstripe.com/doku.php?id=recipes:displaying_five_latest_pages_from_multiple_pagetypes or in second tutorial but im not sure exacly how to write it?
-
Re: Latest article from diferent article holders?

21 October 2008 at 4:01pm
In the category pages:
function Latest() {
return DataObject::get_one("ArticleHolder", "ParentID = $this->ID", "Date DESC");
}Call in your template:
<% if Latest %>
<% control Latest %>
<h3>$Latest.Title</h3>
<div>$Latest.Content</div>
<% end_control %>
<% end_if %> -
Re: Latest article from diferent article holders?

22 October 2008 at 4:44am
ok thanks for reply
i make this in hard way
All subcategory have now their own holders and i use then function from recipe "five lates pages"
| 1606 Views | ||
|
Page:
1
|
Go to Top |



