Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

Pagination


Go to End


15 Posts   7569 Views

Avatar
ScottiouS

Community Member, 54 Posts

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">&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.

Avatar
ScottiouS

Community Member, 54 Posts

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.

Avatar
nodevice

Community Member, 37 Posts

20 May 2007 at 6:34am

Thanks a lot ScottiouS works fine now!!

Avatar
ScottiouS

Community Member, 54 Posts

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"

Avatar
dio5

Community Member, 501 Posts

16 September 2007 at 10:12am

I have a probably stupid question:

why the use of ` in

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

?

Avatar
Sean

Forum Moderator, 922 Posts

16 September 2007 at 12:47pm

Edited: 16/09/2007 12:47pm

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

Cheers,
Sean

Avatar
Matt

Community Member, 86 Posts

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'.

Go to Top