Advertisement
Guest User

Untitled

a guest
Jun 15th, 2011
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.38 KB | None | 0 0
  1. <?php
  2. $profinces_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 != $profinces_cat_id) {
  9.  
  10. // this is main cat (animals or flowers)
  11. // first show links to all subcategories (pigs,cats).
  12. echo 'current category: '.get_cat_name($current_cat). ' - ';
  13. echo 'show links to subcategories';
  14. if($subjects) {
  15. foreach($subjects as $subject) {
  16. echo "<li><a href=\"" . get_category_link($subject->cat_ID) . "?show=map&type=profinces\"><span>". get_cat_name($subject->cat_ID) ."</span></a></li>";
  17. }
  18. }
  19. }
  20.  
  21. } else { // this is a sub category
  22.  
  23. if(!isset($_GET['show'])) { // show same content as type profinces (below)
  24. echo 'current category: '.get_cat_name($current_cat);
  25. $profinces = get_categories('hide_empty=0&parent='.$profinces_cat_id);
  26. foreach($profinces as $profince) {
  27. $sublevel_cat = get_posts(array( 'category__and' => array( $profince->cat_ID, $current_cat ) ) );
  28. if($sublevel_cat) {
  29. 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>";
  30. echo 'category '.get_cat_name($profince->cat_ID).' has post about '.get_cat_name($current_cat);
  31. } else {
  32. 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>";
  33. echo 'category '.get_cat_name($profince->cat_ID).' has no posts about '.get_cat_name($current_cat);
  34. }
  35.  
  36.  
  37.  
  38. }
  39. //echo "<li>Go back to: <a href=\"" . get_category_link($current_cat) . "\"><span>". get_cat_name($current_cat) ."</span></a></li>";
  40. }
  41.  
  42. if(isset($_GET['show']) && $_GET['show'] == 'map') { // show the maps
  43.  
  44. if(isset($_GET['type']) && $_GET['type'] == 'profinces'){
  45. $thisCat_parent = get_category($current_cat,false);
  46. // show map of country with clickable profinces
  47. echo 'show map of country with clickable profinces';
  48. $profinces = get_categories('hide_empty=0&parent='.$profinces_cat_id);
  49. foreach($profinces as $profince) {
  50. if($profince->count == 0){
  51. 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>";
  52. } else {
  53. 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>";
  54. $sublevel_cat = get_posts(array( 'category__and' => array( $profince->cat_ID, $current_cat ) ) );
  55. if($sublevel_cat) {
  56. echo 'category '.get_cat_name($profince->cat_ID).' has post about '.get_cat_name($current_cat);
  57. } else {
  58. echo 'category '.get_cat_name($profince->cat_ID).' has no posts about '.get_cat_name($current_cat);
  59. }
  60.  
  61. }
  62. }
  63. echo "<li>Go back to: <a href=\"" . get_category_link($thisCat_parent->parent) . "\"><span>". get_cat_name($thisCat_parent->parent) ."</span></a></li>";
  64. }
  65.  
  66. if(isset($_GET['type']) && $_GET['type'] == 'profince'){
  67. if(isset($_GET['place_id']) && $_GET['place_id']) {
  68. echo 'show map of profince with clickable regios: '.get_cat_name($_GET['place_id']);
  69. // show map of profince with clickable regios
  70. $regios = get_categories('hide_empty=0&parent='.$_GET['place_id']);
  71. foreach($regios as $regio) {
  72. if($regio->count == 0){
  73. 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>";
  74. } else {
  75. 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>";
  76. $sublevel_cat = get_posts(array( 'category__and' => array( $regio->cat_ID, $current_cat ) ) );
  77. if($sublevel_cat) {
  78. echo 'category '.get_cat_name($regio->cat_ID).' has post about '.get_cat_name($current_cat);
  79. } else {
  80. echo 'category '.get_cat_name($regio->cat_ID).' has no post about '.get_cat_name($current_cat);
  81.  
  82. }
  83. }
  84. }
  85. echo "<li>Go back to: <a href=\"" . get_category_link($current_cat) . "?show=map&type=profinces\"><span>Country map</span></a></li>";
  86. }
  87. }
  88.  
  89. }
  90.  
  91. if(isset($_GET['show']) && $_GET['show'] == 'posts'){
  92. $thisCat_parent = get_category($_GET['place_id'],false);
  93. // show posts here
  94. // you can use these variables for a query
  95. // $current_category = current category (pigs, or cats)
  96. // $_GET['place_id'] = region category id
  97. // $thisCat_parent = $profince
  98.  
  99. echo 'show posts here';
  100. // go back
  101.  
  102. 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>";
  103. }
  104. }
  105.  
  106. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement