- Posts: 28
- Thank you received: 0
OS Property support center
Add cookies and javascript to listing html theme
- Davor
- Topic Author
- Offline
- Junior Member
-
Less
More
10 years 5 months ago #54271
by Davor
Add cookies and javascript to listing html theme was created by Davor
Hello, I would like to modify the listing layout and add grid/list functionality with cookies. I am not sure, but the code isn't working. I added this to the listing.html.tpl.php.
and I added this to the index.php of the main joomla template head
What am I missing?
Thanks
Code:
<script>
$(function(){
var default_view = 'grid'; // choose the view to show by default (grid/list)
// check the presence of the cookie, if not create "view" cookie with the default view value
if($.cookie('view') !== 'undefined'){
$.cookie('view', default_view, { expires: 31, path: '/' });
}
function get_grid(){
$('.list').removeClass('list-active');
$('.grid').addClass('grid-active');
$('.property-view').animate({opacity:0},function(){
$('.property-view').removeClass('property-list');
$('.property-view').addClass('property-grid');
$('.property-view').stop().animate({opacity:1});
});
} // end "get_grid" function
function get_list(){
$('.grid').removeClass('grid-active');
$('.list').addClass('list-active');
$('.property-view').animate({opacity:0},function(){
$('.property-view').removeClass('property-grid');
$('.property-view').addClass('property-list');
$('.property-view').stop().animate({opacity:1});
});
} // end "get_list" function
if($.cookie('view') == 'list'){
// we dont use the "get_list" function here to avoid the animation
$('.grid').removeClass('grid-active');
$('.list').addClass('list-active');
$('.property_view').animate({opacity:0});
$('.property_view').removeClass('property-grid');
$('.property_view').addClass('property-list');
$('.property_view').stop().animate({opacity:1});
}
if($.cookie('view') == 'grid'){
$('.list').removeClass('list-active');
$('.grid').addClass('grid-active');
$('.property_view').animate({opacity:0});
$('.property_view').removeClass('prod-box-list');
$('.property_view').addClass('prod-box');
$('.property_view').stop().animate({opacity:1});
}
$('#list').click(function(){
$.cookie('view', 'list');
get_list()
});
$('#grid').click(function(){
$.cookie('view', 'grid');
get_grid();
});
/* filter */
$('.category-menu ul li').click(function(){
var CategoryID = $(this).attr('category');
$('.category-menu ul li').removeClass('cat-active');
$(this).addClass('cat-active');
$('.property_view').each(function(){
if(($(this).hasClass(CategoryID)) == false){
$(this).css({'display':'none'});
};
});
$('.'+CategoryID).fadeIn();
});
});
</script>
Code:
<link href="<?php echo $templateUrl; ?>/css/grid-list.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo $templateUrl; ?>/jquery.cookie.js"></script>
What am I missing?
Thanks
Please Log in or Create an account to join the conversation.
- Mr. Dam
-
- Offline
- Administrator
-
Less
More
- Posts: 13056
- Thank you received: 1696
10 years 5 months ago #54280
by Mr. Dam
Replied by Mr. Dam on topic Add cookies and javascript to listing html theme
Hi Davor,
I am sorry, i don't know where do you get this source code, but i am afraid it won't work in OS Property. I don't understand that code too.
Thanks
Dam
I am sorry, i don't know where do you get this source code, but i am afraid it won't work in OS Property. I don't understand that code too.
Thanks
Dam
Please Log in or Create an account to join the conversation.
- Davor
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 28
- Thank you received: 0
10 years 5 months ago #54285
by Davor
Replied by Davor on topic Add cookies and javascript to listing html theme
Hello,
This is some jQuery /javascript code with cookies, that I would like to include and execute in listing.html.tpl.php. The main purpose is to add class and remove class on click.
This I would like to incorporate so that I can make a grid and list layout.
Why do you say it won't work? Where can I include the JS code?
Thanks
This is some jQuery /javascript code with cookies, that I would like to include and execute in listing.html.tpl.php. The main purpose is to add class and remove class on click.
Code:
$('.property_view').[b]removeClass[/b]('property-grid');
$('.property_view').[b]addClass[/b]('property-list');
Why do you say it won't work? Where can I include the JS code?
Thanks
Please Log in or Create an account to join the conversation.
- Mr. Dam
-
- Offline
- Administrator
-
Less
More
- Posts: 13056
- Thank you received: 1696
10 years 5 months ago #54294
by Mr. Dam
Replied by Mr. Dam on topic Add cookies and javascript to listing html theme
Hi Davor,
I have read the code you attached in this forum, and to be honest, i don't understand what is the purpose of your code. Hope you understand it. And because i don't understand your code and its purpose, i can't let you know how to make it to work.
I hope someone on this forum will be able to help you something.
Thanks
Dam
I have read the code you attached in this forum, and to be honest, i don't understand what is the purpose of your code. Hope you understand it. And because i don't understand your code and its purpose, i can't let you know how to make it to work.
I hope someone on this forum will be able to help you something.
Thanks
Dam
Please Log in or Create an account to join the conversation.
Moderators: Mr. Dam, Nguyen Phu Quan
Support
Documentation
Information
Copyright © 2025 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.