Keyword

Item Object do not reflect featured items.

More
12 years 11 months ago #57643 by Sam
Hi all,


I'm Kind of new to K2 and I wonder if someone could lend me a little hand.

On the default category_item.php view, there is a call to $item->featured.
Even for items marked as featured on the back-end, the call always returns 0.
So I'm unable to display at the front-end which items are featured.

Should $item->featured return if the article is marked as featured or not?
Am I doing something wrong?

K2 version: 2.4.1


Thanks in advance,
Sam

Please Log in or Create an account to join the conversation.

More
12 years 11 months ago - 12 years 11 months ago #57644 by Sam
I found what was going on reading the source code lines.

The main glue was found at components/com_k2/models/itemlist.php lines 200-207.

//Set featured flag
if ($task == 'category' || empty($task)) {
if (JRequest::getInt('featured') == '0') {
$query .= " AND i.featured != 1";
} else if (JRequest::getInt('featured') == '2') {
$query .= " AND i.featured = 1";
}
}
This code shows that there is a post variable called featured and that it's value changes part of the query sent to the database.

After reading that line of code, I took a careful look at the category parameters and found:
"Featured items" under "Category item layout" -> Other layout options.
This select offers 3 options to choose from:
<option value="0">Hide</option>
<option value="1">Show</option>
<option value="2" selected="selected">Show only featured items</option>

Properly setting it will provide the desired output.

K2 has some excellent features, but it's too redundant when it comes to it's parameters, making it unnecessarily complicated.


Cheers,
Sam

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum