Skip to content

Instantly share code, notes, and snippets.

@neilbradley
Last active December 22, 2015 17:59
Show Gist options
  • Save neilbradley/6509964 to your computer and use it in GitHub Desktop.
Save neilbradley/6509964 to your computer and use it in GitHub Desktop.
Showing categories using Child Categories add-on for EE
{embed="_layouts/index"
google_maps="true"
}
{preload_replace:channel="things-to-do"}
{exp:stash:set_list name="subcategories" parse_tags="yes"}
{exp:child_categories parent="{segment_3_category_id}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no"}
{stash:child_category_start}{child_category_start}{/stash:child_category_start}
{stash:child_category_name}{child_category_name}{/stash:child_category_name}
{stash:child_category_image}{child_category_image}{/stash:child_category_image}
{stash:child_category_description}{child_category_description}{/stash:child_category_description}
{stash:child_category_url_title}{child_category_url_title}{/stash:child_category_url_title}
{stash:child_category_end}{child_category_end}{/stash:child_category_end}
{/exp:child_categories}
{/exp:stash:set_list}
{exp:switchee variable="stash:subcategories" parse="inward"}
{case value="''"}
{exp:stash:set_list name="category_list" parse_tags="yes" parse_depth="3"}
{exp:channel:entries
channel="{channel}"
category="{segment_3_category_id}"
status="open"
orderby="title"
sort="asc"
}
{stash:title}{title}{/stash:title}
{stash:entry_id}{entry_id}{/stash:entry_id}
{stash:url_title}{url_title}{/stash:url_title}
{stash:thingtodo_featured}{thingtodo_featured}{/stash:thingtodo_featured}
{stash:thingtodo_photo_st}{thingtodo_photo_st}{/stash:thingtodo_photo_st}
{stash:thingtodo_shortdescription}{thingtodo_shortdescription}{/stash:thingtodo_shortdescription}
{stash:categories}{categories show_group="1"}{category_name}{/categories}{/stash:categories}
{/exp:channel:entries}
{/exp:stash:set_list}
{exp:stash:set_list name="featured_category_list" parse_tags="yes" parse_depth="3"}
{exp:channel:entries
channel="{channel}"
category="{segment_3_category_id}"
status="open"
orderby="random"
dynamic="no"
}
{stash:title}{title}{/stash:title}
{stash:url_title}{url_title}{/stash:url_title}
{stash:thingtodo_featured}{thingtodo_featured}{/stash:thingtodo_featured}
{stash:thingtodo_photo_st}{thingtodo_photo_st}{/stash:thingtodo_photo_st}
{/exp:channel:entries}
{/exp:stash:set_list}
{exp:stash:set name="content"}
<div class="col mainsection">
<div class="box standardlisting toptagblue">
<div class="featureditems">
{exp:stash:get_list
name="featured_category_list"
match="#Yes#"
against="thingtodo_featured"
cache="yes"
refresh="30"
limit="2"
}
<div class="col featureditem">
<a href="{path='things-to-do/{url_title}'}">
<p>
{exp:ce_img:pair src="{thingtodo_photo_st}" max_width="320" max_height="202" crop="yes|center,center|0,0|yes"}<img src="{made}" alt="{title}" width="{width}" height="{height}" />{/exp:ce_img:pair}
</p>
<p class="featured">Featured</p>
<h1 class="highlightblue">{exp:eehive_hacksaw chars="33" append="..."}{title}{/exp:eehive_hacksaw}</h1><p class="alignright"><a href="{path='things-to-do/{url_title}'}" class="button blackbutton">Find out more</a></p>
</a>
</div>
{/exp:stash:get_list}
<br class="clearFix">
</div>
<div class="itemlistings">
{exp:stash:get_list
name="category_list"
limit="9"
paginate="bottom"
}
{if thingtodo_featured == "Yes"}
<div class="itemlisting itemlisting_highlighted">
{if:else}
<div class="itemlisting">
{/if}
<div class="col itemlistingimage">
<p><a href="{path='things-to-do/{url_title}'}">
{exp:ce_img:pair src="{thingtodo_photo_st}" max_width="182" max_height="121" crop="yes|center,center|0,0|yes"}<img src="{made}" alt="{title}" width="{width}" height="{height}" />{/exp:ce_img:pair}
</a></p>
</div>
<div class="col itemlistinginformation">
<h2><span>{categories}</span><br>{title}</h2>
<p class="description">{thingtodo_shortdescription}</p>
{if logged_in}
<ul class="actionbuttons">
{exp:shortlist:item entry_id="{entry_id}"}
<div class="largeplanner">
<li class="plannerbutton">
{if in_list}
<a href="{site_url}myaccount/planner" rel="view" class="button blackbutton viewplannerbutton">View Planner</a>
{if:else}
<a href="{add_url}" rel="add" class="shortlist_action button blackbutton addtoplannerbutton">Add to Planner</a>
{/if}
</li>
<li><a href="{path='things-to-do/{url_title}'}" class="button bluebutton findoutmorebutton">&raquo; Find out more</a></li>
</div>
{/exp:shortlist:item}
<br class="clearFix">
</ul>
{if:else}
<ul class="actionbuttons">
<li class="plannerbutton"><a class="loggedout_addtoplanner button addtoplannerbutton">Add to Planner</a>
<div class="tooltip">
<div class="loginprompt" id="loginprompt" style="display: block;">
<p>You need to sign in<br>to Add to Planner!</p>
<p class="buttonlink"><a href="{site_url}myaccount" class="button goldbutton">&raquo; Login / Register</a></p>
</div>
</div>
</li>
<li><a href="{path='things-to-do/{url_title}'}" class="button bluebutton findoutmorebutton">&raquo; Find out more</a></li>
<br class="clearFix">
</ul>
{/if}
</div>
<br class="clearFix" />
</div>
{paginate}
<div class="paging">
<div class="col col50">
<p>Page {current_page} of {total_pages}</p>
</div>
{pagination_links}
<div class="col col50 divalignright">
<p>
{previous_page}<a href="{pagination_url}" class="page-previous">&laquo; Previous</a>{/previous_page} {page}<a href="{pagination_url}" class="page-{pagination_page_number} {if current_page}selected{/if}">{pagination_page_number}</a> {/page} {next_page}<a href="{pagination_url}" class="page-next">&raquo; Next</a>{/next_page}
</p>
</div>
{/pagination_links}<br class="clearFix" />
</div>
{/paginate}
{/exp:stash:get_list}
</div>
</div>
</div><!-- end .mainsection -->
<div class="col sidesection">
</div><!-- end .sidesection -->
{/exp:stash:set}
{/case}
{case default="Yes"}
{if segment_2 == 'by2' AND last_segment_category_id == ''}
{redirect="404/index"}
{/if}
{exp:stash:set_list name="featured_category_list" parse_tags="yes" parse_depth="3"}
{exp:channel:entries
channel="{channel}"
category="{segment_3_category_id}"
status="open"
orderby="random"
dynamic="no"
}
{stash:title}{title}{/stash:title}
{stash:url_title}{url_title}{/stash:url_title}
{stash:thingtodo_featured}{thingtodo_featured}{/stash:thingtodo_featured}
{stash:thingtodo_photo_st}{thingtodo_photo_st}{/stash:thingtodo_photo_st}
{/exp:channel:entries}
{/exp:stash:set_list}
{exp:stash:set name="content"}
<div class="col mainsection">
<div class="box standardlisting toptagblue">
<div class="featureditems">
{exp:stash:get_list
name="featured_category_list"
match="#Yes#"
against="thingtodo_featured"
cache="yes"
refresh="30"
limit="2"
}
<div class="col featureditem">
<a href="{path='things-to-do/{url_title}'}">
<p>
{exp:ce_img:pair src="{thingtodo_photo_st}" max_width="320" max_height="202" crop="yes|center,center|0,0|yes"}<img src="{made}" alt="{title}" width="{width}" height="{height}" />{/exp:ce_img:pair}
</p>
<p class="featured">Featured</p>
<h1 class="highlightblue">{exp:eehive_hacksaw chars="33" append="..."}{title}{/exp:eehive_hacksaw}</h1><p class="alignright"><a href="{path='things-to-do/{url_title}'}" class="button blackbutton">Find out more</a></p>
</a>
</div>
{/exp:stash:get_list}
<br class="clearFix">
</div>
</div>
<div class="box">
<h2 class="tagged taggedblue ongrey">Choose By Category</h2>
<p>{segment_3_category_description}</p>
<ul class="thumbgrid thumbgrid_highlightblue">
{exp:stash:get_list name="subcategories"}
<li>
<a href="{child_category_url_title}">{exp:ce_img:pair src="{child_category_image}" max_width="209" max_height="156" crop="yes|center,center|0,0|yes"}<img src="{made}" alt="{child_category_name}" width="{width}" height="{height}" />{/exp:ce_img:pair}</a>
<h3><a href="{child_category_url_title}">&raquo; {child_category_name}</a></h3>
<p>{child_category_description}</p>
</li>
{/exp:stash:get_list}
</ul>
<br class="clearFix" />
</div><!-- end .box -->
</div><!-- end .mainsection -->
<div class="col sidesection">
</div><!-- end .sidesection -->
{/exp:stash:set}
{/case}
{/exp:switchee}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment