- Posts: 3
COMMUNITY FORUM
? Featured items in the order
- Meymen
-
Topic Author
- Offline
- New Member
Please Log in or Create an account to join the conversation.
- Simon Wells
-
- Offline
- Platinum Member
- Posts: 955
Simon
K2 Support
Please Log in or Create an account to join the conversation.
- Meymen
-
Topic Author
- Offline
- New Member
- Posts: 3
Simon
K2 Support
Thank you for your interest Simon.
Good luck
Please Log in or Create an account to join the conversation.
- Kibekas
-
- Offline
- New Member
- Posts: 9
Please Log in or Create an account to join the conversation.
- Terry Britton
-
- Offline
- Elite Member
- Posts: 198
<?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.
- Markus Maier
-
- Offline
- New Member
- Posts: 8
<?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.
- Terry Britton
-
- Offline
- Elite Member
- Posts: 198
<?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.
- Markus Maier
-
- Offline
- New Member
- Posts: 8
<?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.
- Terry Britton
-
- Offline
- Elite Member
- Posts: 198
Please Log in or Create an account to join the conversation.
- Markus Maier
-
- Offline
- New Member
- Posts: 8
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.
- Markus Maier
-
- Offline
- New Member
- Posts: 8
Please Log in or Create an account to join the conversation.
- Terry Britton
-
- Offline
- Elite Member
- Posts: 198
Please Log in or Create an account to join the conversation.
- Markus Maier
-
- Offline
- New Member
- Posts: 8
Please Log in or Create an account to join the conversation.
- Terry Britton
-
- Offline
- Elite Member
- Posts: 198
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.
- Markus Maier
-
- Offline
- New Member
- Posts: 8
Please Log in or Create an account to join the conversation.
- Markus Maier
-
- Offline
- New Member
- Posts: 8
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.
- Terry Britton
-
- Offline
- Elite Member
- Posts: 198
Please Log in or Create an account to join the conversation.
- Markus Maier
-
- Offline
- New Member
- Posts: 8
Please Log in or Create an account to join the conversation.
- Terry Britton
-
- Offline
- Elite Member
- Posts: 198
Please Log in or Create an account to join the conversation.