Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $country_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 != $country_cat_id) {
- // this is main cat (animals or flowers)
- // first show links to all subcategories (pigs,cats).
- if($subjects) {
- foreach($subjects as $subject) {
- echo "<li><a href=\"" . get_category_link($subject->cat_ID) . "?show=map&type=continents\"><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 continents (below)
- $continents = get_categories('hide_empty=0&parent='.$country_cat_id);
- foreach($continents as $continent) {
- echo "<li><a href=\"" . get_category_link($current_cat) . "?show=map&type=continent&place_id=".$continent->cat_ID."\"><span>". get_cat_name($continent->cat_ID) ."</span></a></li>";
- }
- //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'] == 'continents'){
- // show map with continents (Europe, America)
- echo 'show world map';
- $continents = get_categories('hide_empty=0&parent='.$country_cat_id);
- foreach($continents as $continent) {
- echo "<li><a href=\"" . get_category_link($current_cat) . "?show=map&type=continent&place_id=".$continent->cat_ID."\"><span>". get_cat_name($continent->cat_ID) ."</span></a></li>";
- }
- echo "<li>Go back to: <a href=\"" . get_category_link($current_cat) . "\"><span>". get_cat_name($current_cat) ."</span></a></li>";
- }
- if(isset($_GET['type']) && $_GET['type'] == 'continent'){
- if(isset($_GET['place_id']) && $_GET['place_id']) {
- echo 'show continent map';
- // show map with countries (France, England)
- $countries = get_categories('hide_empty=0&parent='.$_GET['place_id']);
- foreach($countries as $country) {
- echo "<li><a href=\"" . get_category_link($current_cat) . "?show=map&type=country&place_id=".$country->cat_ID."\"><span>". get_cat_name($country->cat_ID) ."</span></a></li>";
- }
- echo "<li>Go back to: <a href=\"" . get_category_link($current_cat) . "?show=map&type=continents\"><span>world map</span></a></li>";
- }
- }
- if(isset($_GET['type']) && $_GET['type'] == 'country'){
- if(isset($_GET['place_id']) && $_GET['place_id']) {
- echo 'show country map';
- // show map wth regions (region1, region2)
- $regions = get_categories('hide_empty=0&parent='.$_GET['place_id']);
- foreach($regions as $region) {
- echo "<li><a href=\"" . get_category_link($current_cat) . "?show=posts&type=region&place_id=".$region->cat_ID."\"><span>". get_cat_name($region->cat_ID) ."</span></a></li>";
- }
- $thisCat_parent = get_category($_GET['place_id'],false);
- echo "<li>Go back to: <a href=\"" . get_category_link($current_cat) . "?show=map&type=continent&place_id=".$thisCat_parent->parent."\"><span>". get_cat_name($thisCat_parent->parent) ."</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 = continent (europe)
- echo 'show posts here';
- // go back
- echo "<li>Go back to: <a href=\"" . get_category_link($current_cat) . "?show=map&type=country&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