Keyword

? Featured items in the order

  • Meymen
  • Meymen's Avatar Topic Author
  • Offline
  • New Member
More
15 years 4 days ago #82517 by Meymen
? Featured items in the order was created by Meymen
Hello dear developers.Featured items in the order of items in categories first exit possible?The following section;Category Edit >> Category item layout >> Item ordering >>-Default-Oldest first-Most recent first-Title Alphabetical-Title Reverse-Alphabetical-Ordering-Ordering Reverse-Most popular-Highest rated-Random orderingFeatured items firs. ( If you add this option would be better for K2 component )Thank you for your interest

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

More
15 years 4 days ago #82518 by Simon Wells
Replied by Simon Wells on topic ? Featured items in the order
This has been added to the list, thanks.

Simon
K2 Support

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

  • Meymen
  • Meymen's Avatar Topic Author
  • Offline
  • New Member
More
15 years 3 days ago #82519 by Meymen
Replied by Meymen on topic ? Featured items in the order
K2Joom said:This has been added to the list, thanks.
Simon
K2 Support


Thank you for your interest Simon.
Good luck

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

More
14 years 2 months ago #82520 by Kibekas
Replied by Kibekas on topic ? Featured items in the order
I'm wondering whether this is already possible to do? I.e. featured in top and others sort by date?

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

More
14 years 2 months ago #82521 by Terry Britton
Replied by Terry Britton on topic ? Featured items in the order
Yes it is possible, if you are comfortable with php.  Duplicate the code that calls each item (the foreach statement) and surround each chunk of code as follows.  You should do this in template overrides.

<?php if ($this->item->featured) : ?>

first chunk of code

<?php endif; ?>

<?php if !($this->item->featured): ?>

second chunk of code

<?php endif; ?>

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

More
13 years 11 months ago #82522 by Markus Maier
Replied by Markus Maier on topic ? Featured items in the order
I can't get it to work. My code looks like this. But what I get is no item at all. Any suggestions?:

 

<?php if ($this->item->featured) : ?>            <?php foreach($this->secondary as $key=>$item): ?>                        <?php            // Define a CSS class for the last container on each row            if( (($key+1)%($this->params->get('num_secondary_columns'))==0) || count($this->secondary)<$this->params->get('num_secondary_columns') )                $lastContainer= ' itemContainerLast';            else                $lastContainer='';            ?>                        <div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->secondary)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_secondary_columns'), 1).'%;"'; ?>>                <?php                    // Load category_item.php by default                    $this->item=$item;                    echo $this->loadTemplate('item');                ?>            </div>            <?php if(($key+1)%($this->params->get('num_secondary_columns'))==0): ?>            <div class="clr"></div>            <?php endif; ?>            <?php endforeach; ?>            <?php endif; ?>


Terry A Britton said:

Yes it is possible, if you are comfortable with php.  Duplicate the code that calls each item (the foreach statement) and surround each chunk of code as follows.  You should do this in template overrides.

<?php if ($this->item->featured) : ?>

first chunk of code

<?php endif; ?>

<?php if !($this->item->featured): ?>

second chunk of code

<?php endif; ?>

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

More
13 years 11 months ago #82523 by Terry Britton
Replied by Terry Britton on topic ? Featured items in the order
Sorry my explanation wasn't very good.  The test for the featured status goes inside the foreach loop.

 

            <?php foreach($this->secondary as $key=>$item): ?>

                    <?php if ($this->item->featured) : ?>

...

 

                   <?php endif; ?>            <?php endforeach; ?>

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

More
13 years 11 months ago #82524 by Markus Maier
Replied by Markus Maier on topic ? Featured items in the order
Thanks for getting back so quickly. Unfortunately this doesn't help either. I'm not getting any items. Of course I checked that the "show featured items" is enabled and indeed it is displaying featured items in the overview when I commented out your code. Any other suggestions?

 

<?php foreach($this->secondary as $key=>$item): ?>            <?php if ($this->item->featured) : ?>            <?php            // Define a CSS class for the last container on each row            if( (($key+1)%($this->params->get('num_secondary_columns'))==0) || count($this->secondary)<$this->params->get('num_secondary_columns') )                $lastContainer= ' itemContainerLast';            else                $lastContainer='';            ?>            <div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->secondary)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_secondary_columns'), 1).'%;"'; ?>>                <?php                    // Load category_item.php by default                    $this->item=$item;                    echo $this->loadTemplate('item');                ?>            </div>            <?php if(($key+1)%($this->params->get('num_secondary_columns'))==0): ?>            <div class="clr"></div>            <?php endif; ?>            <?php endif; ?>            <?php endforeach; ?>

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

More
13 years 11 months ago #82525 by Terry Britton
Replied by Terry Britton on topic ? Featured items in the order
Depending on your category layout you can have leading, primary and secondary items, which are each called separately.  The code above will only affect secondary items.  Make the same change to the primary and leading sections ($this->primary and $this-secondary).   As I mentioned earlier in the post you will also have to duplicate the code to call the non-featured items.

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

More
13 years 11 months ago #82526 by Markus Maier
Replied by Markus Maier on topic ? Featured items in the order
I set the primary, leading and links count to 0. Only secondary items are visible right now (featured and non-featured).

 

For testing purposes I didn't dublicate the code I just sourrended the code that calls the secondary items (see above) with your statement. If I'm correct then it should force the code to only show featured items as secondary items. But the area for the secondary items is just empty.

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

More
13 years 11 months ago #82527 by Markus Maier
Replied by Markus Maier on topic ? Featured items in the order
Short update on this. I also tested the 'not show any featured item' if statement. Compared to the statement above it causes the whole website to break. I receive a blank page.

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

More
13 years 11 months ago #82528 by Terry Britton
Replied by Terry Britton on topic ? Featured items in the order
I'll try to play with it this weekend.

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

More
13 years 11 months ago #82529 by Markus Maier
Replied by Markus Maier on topic ? Featured items in the order
Great. Let me know if you need any help.

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

More
13 years 11 months ago #82530 by Terry Britton
Replied by Terry Britton on topic ? Featured items in the order
Hey Markus, just wrap the following portion of the foreach statement as shown.

 

if ($this->item->featured) {

        echo $this->loadTemplate('item');}

 

The syntax for not featured is:

 

if (!$this->item->featured) {

        echo $this->loadTemplate('item');}

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

More
13 years 11 months ago #82531 by Markus Maier
Replied by Markus Maier on topic ? Featured items in the order
Awesome. I will try this and let you know.

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

More
13 years 11 months ago #82532 by Markus Maier
Replied by Markus Maier on topic ? Featured items in the order
It's working Terry. Good job. Unfortunately there's another problem: Your code generates a "itemContainer" div no matter if the 'if-function' matches or not.

This causes a lot of empty div containers that are breaking the layout. For instance if you're working with a two column layout for the secondary items there will be a lot of rows only displaying one item. It's like having empty placeholders.

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

More
13 years 11 months ago #82533 by Terry Britton
Replied by Terry Britton on topic ? Featured items in the order
My first approach was preferrable for just this reason, but I couldn't ever get it to work consistently.  Not sure why.  Give me a link to your site, may be something we can do in css.

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

More
13 years 11 months ago #82534 by Markus Maier
Replied by Markus Maier on topic ? Featured items in the order
Terry - I found a solution for this. I just placed the code snippet in front of the div container...simple but useful.

 

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

More
13 years 11 months ago #82535 by Terry Britton
Replied by Terry Britton on topic ? Featured items in the order
Great. Glad you got it working.

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


Powered by Kunena Forum