Hi,
I am using the Q CMS module on opencart version 149 and to create a blog, using the "articles".
I want the user to be able to add articles and for the most recent articles to appear at the top of the page.
I don't want to use sort order to do it because I think it will become difficult to manage after a few hundred posts have been made.
I thought there would be an easy way of doing this so please correct me if I am going about it like an idiot.
At the moment, if I enable sorting by date, editing catalog/model/cms/article.php and adding:
$sort ='(date.added)'
immediately before
$sql .= " ORDER BY "
Then the first article always appears at the top.
I have tried editing article.php
And replacing the line with:
$sort = '"(array_reverse(a.date_added)"'
In the hope that this would reverse the order of the items, but it didn't work.
I don't know enough about PHP and I want to get this project finished.
Any help is much appreciated,
-J
Solved, in catalog\model\cms\article.php. Found:
if ($order == 'DESC') {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
and replaced it with:
if ($order == 'DESC') {
$sql .= " DESC";
} else {
$sql .= " DESC";
}
Cheers!
-J
if ($order == 'DESC') {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
and replaced it with:
if ($order == 'DESC') {
$sql .= " DESC";
} else {
$sql .= " DESC";
}
Cheers!
-J
"If it can't be fixed with a sledgehammer then it can't be fixed"
Thank you, this helped me out tremendously in combination with changing the code right above that from:
to
...so that it sorts by date instead of alphabetically.
Code: Select all
if (in_array($sort, $sort_data)) {
$sql .= " ORDER BY " . $sort;
} else {
$sql .= " ORDER BY ad.name";
}
Code: Select all
if (in_array($sort, $sort_data)) {
$sort = 'a.date_added';
$sql .= " ORDER BY " . $sort;
} else {
$sql .= " ORDER BY ad.name";
}
Who is online
Users browsing this forum: No registered users and 6 guests