Skip to content

Instantly share code, notes, and snippets.

@neilbradley
Created June 8, 2012 13:29
Show Gist options
  • Save neilbradley/2895613 to your computer and use it in GitHub Desktop.
Save neilbradley/2895613 to your computer and use it in GitHub Desktop.
Viewing category with Switchee
{embed="_layouts/index"}
{preload_replace:channel="case_studies"}
{if group_id=="1"}
{preload_replace:featured_status="featured|closed"}
{preload_replace:preview_status="open|featured|closed"}
{if:else}
{preload_replace:featured_status="featured"}
{preload_replace:preview_status="open|featured"}
{/if}
{exp:switchee variable="{segment_3}" parse="inward"}
{!-- Case Studies listing --}
{case value="#^P(\d+)$#|''"}
{exp:stash:set_value name="title" value="Case Studies | Jack Tighe"}
{exp:stash:set_value name="body_class" value="casestudies"}
{exp:stash:set_value name="body_page" value="case-studies"}
{exp:stash:set_value name="meta_description" value="Case Studies meta"}
{!-- Get downloads related to this page --}
{exp:channel:entries
channel="pages"
status="{preview_status}"
{gv_channel_disable_all}
limit="1"
dynamic="on"
}
{exp:stash:append name="downloads"}
{if cf_page_downloads}
<h3>Downloads</h3>
<ul class="downloads">
{cf_page_downloads}
{exp:jco_getfileinfo filename="{download_file}"}<li><a href="{download_file}" target="_blank" class="{file_extension}">{download_name} [{file_size}]</a></li>{/exp:jco_getfileinfo}
{/cf_page_downloads}
</ul>
{/if}
{/exp:stash:append}
{/exp:channel:entries}
{!-- Get the Case Study categories --}
{exp:stash:append name="categories"}
<form id="newsfilter" name="catmenu" action="">
<select name="selcat" onchange="location=document.catmenu.selcat.options[document.catmenu.selcat.selectedIndex].value;">
<option value="">Please select Category</option>
{exp:channel:categories channel="{channel}" category_group="1" dynamic="off" show_empty="no" style="linear"}
<option value="{path='about-us/case-studies/index'}">{category_name}</option>
{/exp:channel:categories}
</select>
</form>
{/exp:stash:append}
{!-- Get the FEATURED case study item --}
{exp:stash:append name="casestudy_featured"}
{!-- Get featured case study item --}
{exp:low_reorder:entries
channel="{channel}"
status="{featured_status}"
{gv_channel_disable_basic}
set="1"
}
<article class="casestudy">
{if cf_case_client_logo != ''}
{exp:ce_img:pair
src="{cf_case_client_logo}"
height="46"
width="46"
}
<figure class="icon">
<img src="{made}" width="46" height="46" alt="{title}">
</figure>
{/exp:ce_img:pair}
{if:else}
<figure class="icon">
<img src="/images/placeholdergrey46x46.jpg" width="46" height="46" alt="{title}">
</figure>
{/if}
<h1>{title}</h1>
<ul class="sortlist">
<li>in</li>
<li>{categories backspace="2"}<a href="{path='about-us/case-studies/index'}">{category_name}</a>, {/categories}</li>
</ul>
<div class="clear"></div>
{if cf_case_thumbnail != ''}
{exp:ce_img:pair
src="{cf_case_thumbnail}"
height="115"
width="190"
}
<figure>
<a href="/about-us/case-studies/{url_title}">
<img src="{made}" width="190" height="115" alt="{title}">
</a>
</figure>
{/exp:ce_img:pair}
{if:else}
<figure>
<a href="/about-us/case-studies/{url_title}">
<img src="/images/placeholder190x115.jpg" width="190" height="115" alt="{title}">
</a>
</figure>
{/if}
<p>{cf_case_summary} &#187;<a href="/about-us/case-studies/{url_title}"> Continue Reading</a></p>
<div class="clear"></div>
</article>
{/exp:low_reorder:entries}
{/exp:stash:append}
{!-- Get the case study items --}
{exp:stash:append name="casestudy_grid"}
{!-- Get case study items --}
{exp:low_reorder:entries
channel="{channel}"
status="{preview_status}"
{gv_channel_disable_basic}
set="1"
paginate="top"
limit="9"
paginate_base="/about-us/case-studies/"
}
{paginate}
{pagination_links}
<div class="pagination">
<ul>
{previous_page}
<li><a href="{pagination_url}" class="first page-previous">Previous page</a></li><li>//</li>
{/previous_page}
{page}
<li><a href="{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">Page {pagination_page_number}</a></li><li>//</li>
{/page}
{next_page}
<li><a href="{pagination_url}" class="last page-next">Next page</a></li>
{/next_page}
</ul>
</div>
{/pagination_links}
{/paginate}
<article class="{switch='casestudyitem|casestudyitem|casestudyitemlast'}">
<p><a href="/about-us/case-studies/{url_title}">{title}</a></p>
{if cf_case_client_logo != ''}
{exp:ce_img:pair
src="{cf_case_client_logo}"
height="46"
width="46"
}
<figure class="caseicon">
<img src="{made}" width="46" height="46" alt="{title}">
</figure>
{/exp:ce_img:pair}
{if:else}
<figure class="caseicon">
<img src="/images/placeholdergrey46x46.jpg" width="46" height="46" alt="{title}">
</figure>
{/if}
{if cf_case_thumbnail != ''}
{exp:ce_img:pair
src="{cf_case_thumbnail}"
height="115"
width="190"
}
<figure>
<a href="/about-us/case-studies/{url_title}">
<img src="{made}" width="190" height="115" alt="{title}">
</a>
</figure>
{/exp:ce_img:pair}
{if:else}
<figure>
<a href="/about-us/case-studies/{url_title}">
<img src="/images/placeholder190x115.jpg" width="190" height="115" alt="{title}">
</a>
</figure>
{/if}
</article>
{/exp:low_reorder:entries}
{/exp:stash:append}
{exp:stash:set name="asideleft"}
<h3>{structure:top:title}</h3>
<ul>
{exp:structure_entries depth="3" hide_from_nav="yes" parent="/{segment_1}"}
{if {depth} == 1}<li><a href="{page_uri}" class="{if {current_parent}} parent-current{/if}{if {current_page}} current{/if}">{title}</a>{if {children_total} == 0}</li>{/if}
{if:else}
{if {current_sibling} == 0 AND {parent_active} == 0}
</li>
{if:else}
{if {sibling_count} == 1}{!-- First child - so open markup --}
<ul>
{/if}
<li><a href="{page_uri}" class="{if {current_page}} selected{/if}">&#187; {title}</a>
{close_markup}
{if {total_children} == 0 || {depth} == {restricted_depth}}</li>{/if}
{if {last_sibling} && {sibling_count} == {sibling_total}}
</ul>
</li>
{/if}
{/close_markup}
{/if}
{/if}
{/exp:structure_entries}
</ul>
<h3>Filter By</h3>
<ul>
<li>{exp:stash:get name="categories"}</li>
</ul>
{if {exp:stash:not_empty name="downloads"}}
{exp:stash:get name="downloads"}
{/if}
{if {exp:stash:not_empty name="left_floaters"}}
{exp:stash:get name="left_floaters"}
{/if}
{/exp:stash:set}
{exp:stash:set name="content"}
<section class="sectioninfo">
<h3>Featured Case Study</h3>
<hr class="divide">
{exp:stash:get name="casestudy_featured"}
</section>
<hr class="divide">
<section class="sectioninfo">
<h3>All Case Studies</h3>
{exp:stash:get name="casestudy_grid"}
<div class="clear"></div>
<hr class="divide">
{if {exp:stash:not_empty name="content_floaters"}}
{exp:stash:get name="content_floaters"}
{/if}
</section>
{/exp:stash:set}
{/case}
{!-- Single entry --}
{case default="Yes"}
{!-- Get downloads related to this page --}
{exp:channel:entries
channel="pages"
status="{preview_status}"
{gv_channel_disable_all}
limit="1"
dynamic="on"
}
{exp:stash:append name="downloads"}
{if cf_page_downloads}
<h3>Downloads</h3>
<ul class="downloads">
{cf_page_downloads}
{exp:jco_getfileinfo filename="{download_file}"}<li><a href="{download_file}" target="_blank" class="{file_extension}">{download_name} [{file_size}]</a></li>{/exp:jco_getfileinfo}
{/cf_page_downloads}
</ul>
{/if}
{/exp:stash:append}
{/exp:channel:entries}
{!-- Get the Case Study categories --}
{exp:stash:append name="categories"}
<form id="newsfilter" name="catmenu" action="">
<select name="selcat" onchange="location=document.catmenu.selcat.options[document.catmenu.selcat.selectedIndex].value;">
<option value="">Please select Category</option>
{exp:channel:categories channel="{channel}" category_group="1" dynamic="off" show_empty="no" style="linear"}
<option value="{path='about-us/case-studies/index'}">{category_name}</option>
{/exp:channel:categories}
</select>
</form>
{/exp:stash:append}
{exp:stash:set name="asideleft"}
<h3>{structure:top:title}</h3>
<ul>
{exp:structure_entries depth="3" hide_from_nav="yes" parent="/{segment_1}"}
{if {depth} == 1}<li><a href="{page_uri}" class="{if {current_parent}} parent-current{/if}{if {current_page}} current{/if}">{title}</a>{if {children_total} == 0}</li>{/if}
{if:else}
{if {current_sibling} == 0 AND {parent_active} == 0}
</li>
{if:else}
{if {sibling_count} == 1}{!-- First child - so open markup --}
<ul>
{/if}
<li><a href="{page_uri}" class="{if {current_page}} selected{/if}">&#187; {title}</a>
{close_markup}
{if {total_children} == 0 || {depth} == {restricted_depth}}</li>{/if}
{if {last_sibling} && {sibling_count} == {sibling_total}}
</ul>
</li>
{/if}
{/close_markup}
{/if}
{/if}
{/exp:structure_entries}
</ul>
<h3>Filter By</h3>
<ul>
<li>{exp:stash:get name="categories"}</li>
</ul>
{if {exp:stash:not_empty name="downloads"}}
{exp:stash:get name="downloads"}
{/if}
{/exp:stash:set}
{!-- Get the actual case study --}
{exp:channel:entries
channel="{channel}"
limit="1"
status="open|featured"
}
{exp:stash:set_value name="title" value="{title} | Case Studies | Jack Tighe"}
{exp:stash:set_value name="body_class" value="casestudies"}
{exp:stash:set name="content" parse_tags="yes"}
<h1>{title}</h1>
<ul class="sortlist">
<li>in</li>
<li>{categories backspace="2"}<a href="{path='about-us/case-studies/index'}">{category_name}</a>, {/categories}</li>
</ul>
<h2>{cf_case_summary}</h2>
<section class="sectioninfo">
{if cf_case_gallery}
<div class="mygallery2">
{cf_case_gallery limit="1"}
<?php $row = {row_id}; ?>
<div class="panel">
{exp:ce_img:single src="{image}" width="660" height="320" crop="yes|center,center|0,0" attributes='class="largeimage<?php echo $row;?>"'}
</div>
{/cf_case_gallery}
{if "{cf_case_gallery:total_rows}" > 1}
<div class="thumbs<?php echo $row;?>">
{cf_case_gallery}
{exp:ce_img:single src="{image}" width="660" height="320" crop="yes|center,center|0,0" attributes='width="103" height="61"'}
{/cf_case_gallery}
</div>
<script>
$('.thumbs<?php echo $row;?>').delegate('img','click', function(){
$('.largeimage<?php echo $row;?>').attr('src',$(this).attr('src').replace('thumb','large'));
$('.description').html($(this).attr('alt'));
});
</script>
{/if}
</div>
<hr class="divide">
{/if}
{cf_case_body}
<article>
<?php $row = {row_id}; ?>
{if image != '' && image2 != '' && align == 'l'}
<div class="media-left">
<div class="galleryleft">
<div class="mygallery">
<div class="panel">
{if image}{exp:ce_img:single src="{image}" width="320" height="190" crop="yes|center,center|0,0" attributes='class="largeimage<?php echo $row;?>"'}{/if}
</div>
<div class="thumbs<?php echo $row;?>" style="cursor: hand;">
{if image}{exp:ce_img:single src="{image}" width="320" height="190" crop="yes|center,center|0,0" attributes='width="103" height="63"'}{/if}
{if image2}{exp:ce_img:single src="{image2}" width="320" height="190" crop="yes|center,center|0,0" attributes='width="103" height="63"'}{/if}
{if image3}{exp:ce_img:single src="{image3}" width="320" height="190" crop="yes|center,center|0,0" attributes='width="103" height="63"'}{/if}
</div>
</div>
</div>
</div>
{/if}
{if image != '' && image2 != '' && align == 'r'}
<div class="media-right">
<div class="galleryright">
<div class="mygallery">
<div class="panel">
{if image}{exp:ce_img:single src="{image}" width="320" height="190" crop="yes|center,center|0,0" attributes='class="largeimage<?php echo $row;?>"'}{/if}
</div>
<div class="thumbs<?php echo $row;?>" style="cursor: hand;">
{if image}{exp:ce_img:single src="{image}" width="320" height="190" crop="yes|center,center|0,0" attributes='width="103" height="63"'}{/if}
{if image2}{exp:ce_img:single src="{image2}" width="320" height="190" crop="yes|center,center|0,0" attributes='width="103" height="63"'}{/if}
{if image3}{exp:ce_img:single src="{image3}" width="320" height="190" crop="yes|center,center|0,0" attributes='width="103" height="63"'}{/if}
</div>
</div>
</div>
</div>
{/if}
{if image && image2 == '' && align == 'l'}
<figure class="media-left">
{exp:ce_img:single src="{image}" width="326" height="245" crop="yes|center,center|0,0"}
<figcaption>{caption}</figcaption>
</figure>
{/if}
{if image && image2 == '' && align == 'r'}
<figure class="media-right">
{exp:ce_img:single src="{image}" width="326" height="245" crop="yes|center,center|0,0"}
<figcaption>{caption}</figcaption>
</figure>
{/if}
{if video && align == 'l'}<div class="media-left"><iframe src="http://player.vimeo.com/video/{video}?color=A9242B" width="326" height="183" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>{/if}
{if video && align == 'r'}<div class="media-right"><iframe src="http://player.vimeo.com/video/{video}?color=A9242B" width="326" height="183" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>{/if}
{text}
<script>
$('.thumbs<?php echo $row;?>').delegate('img','click', function(){
$('.largeimage<?php echo $row;?>').attr('src',$(this).attr('src').replace('thumb','large'));
$('.description').html($(this).attr('alt'));
});
</script>
<hr class="divide">
</article>
{/cf_case_body}
{/exp:channel:entries}
{!-- Related case studies here --}
<h3>Related Case Studies</h3>
{exp:channel:entries related_categories_mode="yes" limit="3" status="{preview_status}" custom_fields="yes"}
{if no_results}<li>No more news available in this category. Please visit our <a href="{site_url}news">News</a> page for more.</li>{/if}
<article class="casestudy{switch='item|item|itemlast'}">
<p><a href="/about-us/case-studies/{url_title}">{title}</a></p>
{if cf_case_client_logo != ''}
{exp:ce_img:pair
src="{cf_case_client_logo}"
height="46"
width="46"
}
<figure class="caseicon">
<img src="{made}" width="46" height="46" alt="{title}">
</figure>
{/exp:ce_img:pair}
{if:else}
<figure class="caseicon">
<img src="/images/placeholdergrey46x46.jpg" width="46" height="46" alt="{title}">
</figure>
{/if}
{if cf_case_thumbnail != ''}
{exp:ce_img:pair
src="{cf_case_thumbnail}"
height="115"
width="190"
}
<figure>
<a href="/about-us/case-studies/{url_title}">
<img src="{made}" width="190" height="115" alt="{title}">
</a>
</figure>
{/exp:ce_img:pair}
{if:else}
<figure>
<a href="/about-us/case-studies/{url_title}">
<img src="/images/placeholder190x115.jpg" width="190" height="115" alt="{title}">
</a>
</figure>
{/if}
</article>
{/exp:channel:entries}
<div class="clear"></div>
<hr class="divide">
{!-- Floaters here --}
</section>
{/exp:stash:set}
{/case}
{/exp:switchee}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment