Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

1154 Posts in 324 Topics by 274 members

Data Model Questions

SilverStripe Forums » Data Model Questions » how to show the last 3 pages from the specified section

Page: 1
Go to End
Author Topic: how to show the last 3 pages from the specified section 370 Views
  • fiord
    avatar
    Community Member
    50 posts

    how to show the last 3 pages from the specified section Link to this post

    I have several sections like NewsHolder
    On my MainPage I want to show grups of the las 3 children page

    3 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 Error

    Parse 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?

  • Sam
    avatar
    Administrator
    649 posts

    Re: how to show the last 3 pages from the specified section Link to this post

    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.

  • fiord
    avatar
    Community Member
    50 posts

    Re: how to show the last 3 pages from the specified section Link to this post

    great thanks
    I thought that I will dance all night with timbrel

    370 Views
Page: 1
Go to Top

Currently Online: There is nobody online.

Welcome to our latest member: GreenWork

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.