Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $profinces_cat_id = 51;
- $current_cat = get_query_var('cat');
- $thisCat = get_category($current_cat,false);
- $subjects= get_categories('hide_empty=0&child_of='.$current_cat);
- if($thisCat->parent == 0){ // top level category
- if($current_cat != $profinces_cat_id) {
- // this is main cat (animals or flowers)
- // first show links to all subcategories (pigs,cats).
- echo 'current category: '.get_cat_name($current_cat). ' - ';
- echo 'show links to subcategories';
- if($subjects) {
- foreach($subjects as $subject) {
- echo "<li><a href=\"" . get_category_link($subject->cat_ID) . "?show=map&type=profinces\"><span>". get_cat_name($subject->cat_ID) ."</span></a></li>";
- }
- }
- }
- } else { // this is a sub category
- if(!isset($_GET['show'])) { // show same content as type profinces (below)
- echo 'current category: '.get_cat_name($current_cat);
- $profinces = get_categories('hide_empty=0&parent='.$profinces_cat_id);
- foreach($profinces as $profince) {
- $sublevel_cat = get_posts(array( 'category__and' => array( $profince->cat_ID, $current_cat ) ) );
- if($sublevel_cat) {
- echo "<li><a href=\"" . get_category_link($current_cat) . "?show=map&type=profince&place_id=".$profince->cat_ID."\"><span>". get_cat_name($profince->cat_ID) ."</span></a></li>";
- echo 'category '.get_cat_name($profince->cat_ID).' has post about '.get_cat_name($current_cat);
- } else {
- echo "<li><a href=\"" . get_category_link($current_cat) . "?show=map&type=profince&place_id=".$profince->cat_ID."\"><span>". get_cat_name($profince->cat_ID) ."</span></a></li>";
- echo 'category '.get_cat_name($profince->cat_ID).' has no posts about '.get_cat_name($current_cat);
- }
- }
- //echo "<li>Go back to: <a href=\"" . get_category_link($current_cat) . "\"><span>". get_cat_name($current_cat) ."</span></a></li>";
- }
- if(isset($_GET['show']) && $_GET['show'] == 'map') { // show the maps
- if(isset($_GET['type']) && $_GET['type'] == 'profinces'){
- $thisCat_parent = get_category($current_cat,false);
- // show map of country with clickable profinces
- echo 'show map of country with clickable profinces';
- $profinces = get_categories('hide_empty=0&parent='.$profinces_cat_id);
- foreach($profinces as $profince) {
- if($profince->count == 0){
- echo "<li><a href=\"" . get_category_link($current_cat) . "?show=map&type=profince&place_id=".$profince->cat_ID."\"><span>". get_cat_name($profince->cat_ID) ."</span></a> has no posts</li>";
- } else {
- echo "<li><a href=\"" . get_category_link($current_cat) . "?show=map&type=profince&place_id=".$profince->cat_ID."\"><span>". get_cat_name($profince->cat_ID) ."</span></a> has posts</li>";
- $sublevel_cat = get_posts(array( 'category__and' => array( $profince->cat_ID, $current_cat ) ) );
- if($sublevel_cat) {
- echo 'category '.get_cat_name($profince->cat_ID).' has post about '.get_cat_name($current_cat);
- } else {
- echo 'category '.get_cat_name($profince->cat_ID).' has no posts about '.get_cat_name($current_cat);
- }
- }
- }
- echo "<li>Go back to: <a href=\"" . get_category_link($thisCat_parent->parent) . "\"><span>". get_cat_name($thisCat_parent->parent) ."</span></a></li>";
- }
- if(isset($_GET['type']) && $_GET['type'] == 'profince'){
- if(isset($_GET['place_id']) && $_GET['place_id']) {
- echo 'show map of profince with clickable regios: '.get_cat_name($_GET['place_id']);
- // show map of profince with clickable regios
- $regios = get_categories('hide_empty=0&parent='.$_GET['place_id']);
- foreach($regios as $regio) {
- if($regio->count == 0){
- echo "<li><a href=\"" . get_category_link($current_cat) . "?show=posts&type=regio&place_id=".$regio->cat_ID."\"><span>". get_cat_name($regio->cat_ID) ."</span></a> has no posts</li>";
- } else {
- echo "<li><a href=\"" . get_category_link($current_cat) . "?show=posts&type=regio&place_id=".$regio->cat_ID."\"><span>". get_cat_name($regio->cat_ID) ."</span></a> has posts</li>";
- $sublevel_cat = get_posts(array( 'category__and' => array( $regio->cat_ID, $current_cat ) ) );
- if($sublevel_cat) {
- echo 'category '.get_cat_name($regio->cat_ID).' has post about '.get_cat_name($current_cat);
- } else {
- echo 'category '.get_cat_name($regio->cat_ID).' has no post about '.get_cat_name($current_cat);
- }
- }
- }
- echo "<li>Go back to: <a href=\"" . get_category_link($current_cat) . "?show=map&type=profinces\"><span>Country map</span></a></li>";
- }
- }
- }
- if(isset($_GET['show']) && $_GET['show'] == 'posts'){
- $thisCat_parent = get_category($_GET['place_id'],false);
- // show posts here
- // you can use these variables for a query
- // $current_category = current category (pigs, or cats)
- // $_GET['place_id'] = region category id
- // $thisCat_parent = $profince
- echo 'show posts here';
- // go back
- echo "<li>Go back to: <a href=\"" . get_category_link($current_cat) . "?show=map&type=profince&place_id=".$thisCat_parent->parent."\"><span>". get_cat_name($thisCat_parent->parent) ."</span></a></li>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement