Advertisement
kneops

sample

Jun 15th, 2011
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.11 KB | None | 0 0
  1. <?php
  2. $provinces_cat_id = 6;
  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(isset($_GET['show']) && $_GET['show'] == 'map') { // show the maps
  8.     if(isset($_GET['type']) && $_GET['type'] == 'provinces'){
  9.         $thisCat_parent = get_category($current_cat,false);
  10.         // show map of country with clickable provinces
  11.         echo 'show map of country with clickable provinces';
  12.         $provinces = get_categories('hide_empty=0&exclude=1&orderby=slug&order=ASC&parent='.$provinces_cat_id);
  13.         echo "<ul class=\"country\">";
  14.             foreach($provinces as $province) {
  15.                 $postsinregions = get_posts('hide_empty=0&category='.$province->cat_ID);
  16.             if(!$postsinregions) {
  17.                 echo "<li class=\"".$province->cat_name."\"></li>";
  18.                     } else {
  19.                     echo "<li class=\"".$province->cat_name."\"><a href=\"" . get_category_link($current_cat) . "?show=map&type=regio&place_id=".$province->cat_ID."\"><span>". get_cat_name($province->cat_ID) ."</span></a> has posts</li>";
  20.                     $sublevel_cat = get_posts(array( 'category__and' => array( $province->cat_ID, $current_cat ) ) );
  21.                         if($sublevel_cat) {
  22.                             echo 'category '.get_cat_name($province->cat_ID).' has post about '.get_cat_name($current_cat);
  23.                         } else {
  24.                             echo 'category '.get_cat_name($province->cat_ID).' has no posts about '.get_cat_name($current_cat);
  25.                             }
  26.             }
  27.         }
  28.         echo "</ul>";
  29.         echo "<li>Go back to: <a href=\"" . get_category_link($thisCat_parent->parent) . "\"><span>". get_cat_name($thisCat_parent->parent) ."</span></a></li>";
  30.     }
  31. }
  32.  
  33.  
  34.  
  35. if(isset($_GET['type']) && $_GET['type'] == 'regio') {
  36.     if(isset($_GET['place_id']) && $_GET['place_id']) {
  37.         echo 'show map of province with clickable regios: '.get_cat_name($_GET['place_id']);
  38.         // show map of province with clickable regios
  39.             $regios = get_categories('hide_empty=0&exclude=1&orderby=slug&order=ASC&parent='.$_GET['place_id']);
  40.         $catid = $_GET['place_id'];
  41.         $catname = get_cat_name($catid);
  42.         echo "<ul class=\"Province-" . $catname . "\">";
  43.         $i = 1;
  44.             foreach($regios as $regio) {
  45.                 $postsinregions = get_posts('hide_empty=0&category='.$regio->cat_ID);
  46.             if(!$postsinregions) {
  47.             echo "<li class=\"regio".$i."\"></li>";
  48.             } else {
  49.                 echo "<li class=\"regio".$i."\"><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>";
  50.                 $sublevel_cat = get_posts(array( 'category__and' => array( $regio->cat_ID, $current_cat ) ) );
  51.                     if($sublevel_cat) {
  52.                         echo 'category '.get_cat_name($regio->cat_ID).' has post about '.get_cat_name($current_cat);
  53.                     } else {
  54.                         echo 'category '.get_cat_name($regio->cat_ID).' has no post about '.get_cat_name($current_cat);
  55.                 }
  56.                
  57.         $i++;
  58.         }
  59.         echo "</ul>";
  60.         echo "<li>Go back to: <a href=\"" . get_category_link($current_cat) . "?show=map&type=provinces\"><span>Country map</span></a></li>";
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement