17488 Posts in 4473 Topics by 1978 members
| Go to End | ||
| Author | Topic: | 5618 Views |
-
Re: Pagination

19 May 2007 at 10:27pm
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"><< Prev</a> |
And:
| <a href="$NewsArticles.NextLink">Next >></a>
to:
| <a href="$NewsArticles.NextLink">Next >></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.
-
Re: Pagination

19 May 2007 at 11:02pm
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.
-
Re: Pagination

6 August 2007 at 10:28am
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"
-
Re: Pagination

16 September 2007 at 10:12am
I have a probably stupid question:
why the use of ` in
$filter = "`ParentID` = '".$this->ID."'",
?
-
Re: Pagination

16 September 2007 at 12:47pm Last edited: 16 September 2007 12:47pm
I believe the ` character (a backtick), is used to reserve names of tables and columns in a SQL query...
Cheers,
Sean -
Re: Pagination

16 September 2007 at 7:13pm
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'.
| 5618 Views | ||
| Go to Top |





