Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Pagination

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1 2
Go to End
Author Topic: 6002 Views
  • ScottiouS
    Avatar
    Community Member
    54 Posts

    Re: Pagination Link to this post

    Hey nodevice,

    I tried this code and had the same probs. I manaed to figure it out though..

    In the ArticleHolder.ss change:
        <a href="$NewsArticles.PrevLink"><< Prev</a> |
    to:
        <a href="$NewsArticles.PrevLink">&lt;&lt; Prev</a> |
    And:
        | <a href="$NewsArticles.NextLink">Next >></a>
    to:
        | <a href="$NewsArticles.NextLink">Next &gt;&gt;</a>

    And in the ArticleHolder.php change:
        $callerClass = "NewsArticle",
    to:
        $callerClass = "ArticlePage",

    Minor changes, thanks for the code Matt. You might want to update the wiki.

  • ScottiouS
    Avatar
    Community Member
    54 Posts

    Re: Pagination Link to this post

    Another point on this.. you may want to add in the order of the articles. This is probably obvious but for those which it isn't:

    In change ArticleHolder.php change:
        $sort = "",
    to:
        $sort = "Date DESC",

    Then you'll get the latest article showing first.

  • nodevice
    Avatar
    Community Member
    37 Posts

    Re: Pagination Link to this post

    Thanks a lot ScottiouS works fine now!!

  • ScottiouS
    Avatar
    Community Member
    54 Posts

    Re: Pagination Link to this post

    I have found that with the order of articles displaying that if you have more than one article on the same day (date) and you are ordering by DATE then it will display the first one published at the top and the following ones below. To get past this I added ordering on the ID also. Although not optimal as ID's may be reused it does at least fix the problem in most cases.

    So instead of just "Date DESC" put this in the SQL:

    $sort = "Date DESC, `ArticlePage_Live`.ID DESC"

    Or if your model is named `NewsArticle` then:

    $sort = "Date DESC, `NewsArticle_Live`.ID DESC"

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: Pagination Link to this post

    I have a probably stupid question:

    why the use of ` in

    $filter = "`ParentID` = '".$this->ID."'",

    ?

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Pagination Link to this post

    I believe the ` character (a backtick), is used to reserve names of tables and columns in a SQL query...

    Cheers,
    Sean

  • Matt
    Avatar
    Core Development Team
    84 Posts

    Re: Pagination Link to this post

    Sean's right - in MySQL at least, the backtick is used to differentiate MySQL keywords and table/column names. For example, ORDER is a MySQL keyword, but `ORDER` will make MySQL look for the 'ORDER' column.

    It's handy when you have tables that uses columns such as 'order'.

    6002 Views
Page: 1 2
Go to Top

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

Comments on this website? Please give feedback.