2508 Posts in 675 Topics by 520 members
Data Model Questions
SilverStripe Forums » Data Model Questions » how to show the last 3 pages from the specified section
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 731 Views |
-
how to show the last 3 pages from the specified section

24 February 2009 at 6:48am
I have several sections like NewsHolder
On my MainPage I want to show grups of the las 3 children page3 Latest News From NewsHolder [1]
-NewsPageName [Last]
-NewsPageName [Last-1]
-NewsPageName [Last-2]3 Latest News From NewsHolder [2]
-NewsPageName [Last]
-NewsPageName [Last-1]
-NewsPageName [Last-2]3 Latest News From NewsHolder [3]
-NewsPageName [Last]
-NewsPageName [Last-1]
-NewsPageName [Last-2]on the forum I found a function for my MainPage
function NewsList($num=3, $ParentURL='news') {
$news = DataObject::get_one("NewsHolder", "URLSegment = '$ParentURL'");
return ($news) ? DataObject::get("NewsPage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
}but it does not work when I sets $ParentURL
<% control NewsList(3, $NewsHolder1URL) %>
<div class="newsBl2">
<div class="date">$Date.Nice</div>
<a href="$Link" title="$Title.XML" class="newsH"><img src="img/newsHead/{$ID}.png" alt="$Title.XML" /></a>
<div class="NewsDesc">$NewsDesc </div>
</div>
<% end_control %>
I have next ErrorParse error: syntax error, unexpected '}' in C:\Users\vitaliy\AppData\Local\Temp\silverstripe-cacheV--home-p.org.ua-www-harley-davidson\.cacheV..home.p.org.ua.www.harley-davidson.themes.harley.templates.Layout.MainPage.ss on line 197
What am I doing wrong?
-
Re: how to show the last 3 pages from the specified section

24 February 2009 at 8:53am
You can't put a $ reference in the control. The template language doesn't work that way.
Instead, update NewsList() to refer to $this->NewsHolder1URL and then do away with the 2nd argument altogether.
-
Re: how to show the last 3 pages from the specified section

24 February 2009 at 10:01am
great thanks
I thought that I will dance all night with timbrel
| 731 Views | ||
|
Page:
1
|
Go to Top |


