- Posts: 91
- Thank you received: 5
Dynamic view change on frontend
9 years 4 months ago #270457
by bolando
Dynamic view change on frontend was created by bolando
-- HikaShop version -- : 3.1.0
-- Joomla version -- : 3.7.2
-- PHP version -- : 7.0
-- Browser(s) name and version -- : Chrome latest
Does anybody know how to introduce an option in frontend to dynamically switch the view between div (grid) mode and list/table mode? I attach the icons on non-hika site that make it.
-- Joomla version -- : 3.7.2
-- PHP version -- : 7.0
-- Browser(s) name and version -- : Chrome latest
Does anybody know how to introduce an option in frontend to dynamically switch the view between div (grid) mode and list/table mode? I attach the icons on non-hika site that make it.
Please Log in or Create an account to join the conversation.
9 years 4 months ago - 9 years 4 months ago #270464
by Philip
Replied by Philip on topic Dynamic view change on frontend
Hello,
there is no options to do this in HikaShop.
BUT I see 2 solutions to fit your needs :
1°) You can create 2 Item Menu listing, 1 with div display configuration AND 1 (with the same products & categories content) but with table display configuration.
One of this Item Menu have to be created in "HikaShop hidden menus" to avoid to have 2 times the "same" name menu in your menu listing.
Then, add via override view on your menu listing 2 buttons WITH required Url to reach one of the other Item Menu.
Maybe if you have some menu listing that don't required this kind of feature, you have to add in your override view a condition to display or not these 2 buttons.
Something like :
See these 2 tutorials, to help you, on
Item Menu
and
Override View
.
Hope this will help you.
Regards
there is no options to do this in HikaShop.
BUT I see 2 solutions to fit your needs :
1°) You can create 2 Item Menu listing, 1 with div display configuration AND 1 (with the same products & categories content) but with table display configuration.
One of this Item Menu have to be created in "HikaShop hidden menus" to avoid to have 2 times the "same" name menu in your menu listing.
Then, add via override view on your menu listing 2 buttons WITH required Url to reach one of the other Item Menu.
Maybe if you have some menu listing that don't required this kind of feature, you have to add in your override view a condition to display or not these 2 buttons.
Something like :
Code:
if (menu_listing_id == required_menu_id) {
echo
"<div class='buttons'>...</div>".
"<div class='buttons'>...</div>";
}
Hope this will help you.
Regards
Last edit: 9 years 4 months ago by Philip.
Please Log in or Create an account to join the conversation.
9 years 4 months ago #270539
by bolando
Replied by bolando on topic Dynamic view change on frontend
Thanks, I will try it and maybe give some feedback
Please Log in or Create an account to join the conversation.
9 years 1 month ago - 9 years 1 month ago #275664
by bolando
Replied by bolando on topic Dynamic view change on frontend
Hey, I managed to do this.
1) I created template override:
html/com_hikashop/product/listing_img_title.php
and in line 72 I added
2) I added switch buttons with jQuery:
3) Then I added the click behaviour:
4) I added CSS rules:
5) Finally I even addes Cookie rules, so If any client prefers 1 column view, he will get it as default in all categories. So the full code from 3) looks like this
I used
github.com/js-cookie/js-cookie
for this, so I had to include
in my template.
The result of 1 column view is attached.
I hope that can be of help to anyone.
1) I created template override:
html/com_hikashop/product/listing_img_title.php
and in line 72 I added
Code:
<span class="hikashop_product_opis">
<?php echo $this->row->product_description; ?>
</span>
Code:
jQuery('.sortowanie').before('<div id=switch>Widok: <a id="3kol" href=#><img src="/new/images/icons/widok2.png" alt="3 kolumny" /></a> <a id="1kol" href=#><img src="/new/images/icons/widok1.png" alt="1 kolumna z opisem" /></a></div>');
Code:
jQuery('#1kol').click(function(e){
e.preventDefault();
jQuery('.hikashop_products_listing_main').addClass('kolumna1');
});
jQuery('#3kol').click(function(e){
e.preventDefault();
jQuery('.hikashop_products_listing_main').removeClass('kolumna1');
})
Code:
.hikashop_product_opis {
display:none;
}
.kolumna1 .hkc-md-4 {
width:100% !important;
}
.kolumna1 .hikashop_product_opis {
display:block
}
.kolumna1 .hikashop_product_image {
float:left;
}
Code:
var Cookies2 = Cookies.noConflict();
jQuery('#1kol').click(function(e){
e.preventDefault();
jQuery('.hikashop_products_listing_main').addClass('kolumna1');
Cookies2.set('widok', '1kol');
});
jQuery('#3kol').click(function(e){
e.preventDefault();
jQuery('.hikashop_products_listing_main').removeClass('kolumna1');
Cookies2.set('widok', '3kol');
})
var widok = Cookies2.get('widok');
//console.log(widok);
if (widok == '1kol')
{
jQuery('#1kol').click();
}
Code:
<script src="<?php echo $this->baseurl . '/templates/' . $this->template . '/js/js.cookie.js' ?>"></script>
The result of 1 column view is attached.
I hope that can be of help to anyone.
Last edit: 9 years 1 month ago by bolando. Reason: cookies2 explanation
The following user(s) said Thank You: nicolas
Please Log in or Create an account to join the conversation.
Time to create page: 0.218 seconds