This theme comes with a filterable gallery using the jQuery plugin Masonry and a custom filter script. I've created an instance in ListIt2 and built my summary template with this category template included/embedded:
Code: Select all
<!-- categories -->
<section class="filter">
<a href="#">all</a>
{foreach from=$categories item=category}
<a href="#{$category->name}">{$category->name}</a>
{/foreach}
</section>
<!-- categories //-->
But when I try it in CMSms the hash in each filter link causes the page to redirect to the homepage. I know this is a default behavior in CMSms so I started searching for a workaround and found this online:
Code: Select all
<__script__ type="text/javascript">
/* <![CDATA[ */
( function( $ ) {
$( 'a[href="#"]' ).click( function(e) {
e.preventDefault();
} );
} )( jQuery );
/* ]]> */
</__script>
I narrowed it down to this bit of code in the custom Jquery filter:
Code: Select all
$('.filter').each(function() {
var links = $('> a', this);
var items = $(this).next('.items');
links.click(function() {
var category = $(this).attr('href').substr(1);
if (category == '') {
$('.item', items).removeClass('hidden').fadeIn(250);
} else { Yadda, Yadda
}
Code: Select all
$('.filter').each(function() {
var links = $('> a', this);
var items = $(this).next('.items');
links.click(function(e) {
e.preventDefault();
var category = $(this).attr('href').substr(1);
if (category == '') {
$('.item', items).removeClass('hidden').fadeIn(250);
} else { Yadda, Yadda
}
The filter worked perfectly and the hash links work as expected.
Simon66