Advertisement
Guest User

Untitled

a guest
Jun 15th, 2011
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. <?php
  2. $country_cat_id = 51;
  3. $current_cat = get_query_var('cat');
  4. $thisCat = get_category($current_cat,false);
  5. $subjects= get_categories('hide_empty=0&child_of='.$current_cat);
  6.  
  7. if($thisCat->parent == 0){ // top level category
  8. if($current_cat != $country_cat_id) {
  9.  
  10. // this is main cat (animals or flowers)
  11. // first show links to all subcategories (pigs,cats).
  12. if($subjects) {
  13. foreach($subjects as $subject) {
  14. echo "<li><a href=\"" . get_category_link($subject->cat_ID) . "?show=map&type=continents\"><span>". get_cat_name($subject->cat_ID) ."</span></a></li>";
  15. }
  16. }
  17. }
  18.  
  19. } else { // this is a sub category
  20.  
  21. if(!isset($_GET['show'])) { // show same content as type continents (below)
  22. $continents = get_categories('hide_empty=0&parent='.$country_cat_id);
  23. foreach($continents as $continent) {
  24. 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>";
  25. }
  26. //echo "<li>Go back to: <a href=\"" . get_category_link($current_cat) . "\"><span>". get_cat_name($current_cat) ."</span></a></li>";
  27. }
  28.  
  29. if(isset($_GET['show']) && $_GET['show'] == 'map') { // show the maps
  30.  
  31. if(isset($_GET['type']) && $_GET['type'] == 'continents'){
  32. // show map with continents (Europe, America)
  33. echo 'show world map';
  34. $continents = get_categories('hide_empty=0&parent='.$country_cat_id);
  35. foreach($continents as $continent) {
  36. 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>";
  37. }
  38. echo "<li>Go back to: <a href=\"" . get_category_link($current_cat) . "\"><span>". get_cat_name($current_cat) ."</span></a></li>";
  39. }
  40.  
  41. if(isset($_GET['type']) && $_GET['type'] == 'continent'){
  42. if(isset($_GET['place_id']) && $_GET['place_id']) {
  43. echo 'show continent map';
  44. // show map with countries (France, England)
  45. $countries = get_categories('hide_empty=0&parent='.$_GET['place_id']);
  46. foreach($countries as $country) {
  47. 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>";
  48. }
  49. echo "<li>Go back to: <a href=\"" . get_category_link($current_cat) . "?show=map&type=continents\"><span>world map</span></a></li>";
  50. }
  51. }
  52.  
  53. if(isset($_GET['type']) && $_GET['type'] == 'country'){
  54. if(isset($_GET['place_id']) && $_GET['place_id']) {
  55. echo 'show country map';
  56. // show map wth regions (region1, region2)
  57. $regions = get_categories('hide_empty=0&parent='.$_GET['place_id']);
  58. foreach($regions as $region) {
  59. 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>";
  60. }
  61. $thisCat_parent = get_category($_GET['place_id'],false);
  62. 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>";
  63. }
  64. }
  65. }
  66.  
  67. if(isset($_GET['show']) && $_GET['show'] == 'posts'){
  68. $thisCat_parent = get_category($_GET['place_id'],false);
  69. // show posts here
  70. // you can use these variables for a query
  71. // $current_category = current category (pigs, or cats)
  72. // $_GET['place_id'] = region category id
  73. // $thisCat_parent = continent (europe)
  74.  
  75. echo 'show posts here';
  76. // go back
  77.  
  78. 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>";
  79. }
  80. }
  81.  
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement