Listing Categories on Form

Discussion in 'GeoCraft WordPress Theme' started by spoonboy90, Dec 6, 2013.

  1. spoonboy90

    spoonboy90 Active Member

    Joined:
    Dec 20, 2012
    Messages:
    289
    Likes Received:
    28
    Location:
    Stoke-on-Trent, Staffordshire. UK
    I'm trying to get it so the Category selection field on the form only displays the main/top level categories without their childres, i belive it to be possible and the answer lying somewhere in the listing_submit_form.php & dashboard_functions.php but my attempts so far have resulted in failure.

    If you could tell me which code to omit I would be very greatful

    Thanks
    Jamie
     
  2. spoonboy90

    spoonboy90 Active Member

    Joined:
    Dec 20, 2012
    Messages:
    289
    Likes Received:
    28
    Location:
    Stoke-on-Trent, Staffordshire. UK
    I know as soon as I posted i'd resolve it...

    Sorry, for anyone else interested in this remove the code below from

    /themes/geocrafttheme/library/front_end/listing_submit_form.php

    Code:
    if ($acb_cat) {
                                    echo "<ul class=\"children\">";
                                    foreach ($acb_cat as $child_of) {
                                        $term = get_term_by('id', $child_of->term_id, CUSTOM_CAT_TYPE);
                                        $termid = $term->term_taxonomy_id;
                                        $term_tax_id = $term->term_id;
                                        $name = $term->name;
                                        ?>
                                        <li><label><input class="list_category" type="checkbox" name="category[]" id="<?php echo $termid; ?>" value="<?php echo $name; ?>" class="checkbox" /><?php echo $name; ?></label></li>
                                        <?php
                                        $args = array(
                                            'type' => POST_TYPE,
                                            'child_of' => '',
                                            'parent' => $term_tax_id,
                                            'orderby' => 'name',
                                            'order' => 'ASC',
                                            'hide_empty' => 0,
                                            'hierarchical' => 1,
                                            'exclude' => $term_tax_id,
                                            'include' => '',
                                            'number' => '',
                                            'taxonomy' => CUSTOM_CAT_TYPE,
                                            'pad_counts' => false);
                                        $acb_cat = get_categories($args);
                                        if ($acb_cat) {
                                            echo "<ul class=\"children\">";
                                            foreach ($acb_cat as $child_of) {
                                                $term = get_term_by('id', $child_of->term_id, CUSTOM_CAT_TYPE);
                                                $termid = $term->term_taxonomy_id;
                                                $term_tax_id = $term->term_id;
                                                $name = $term->name;
                                                ?>
                                                <li><label><input class="list_category" type="checkbox" name="category[]" id="<?php echo $termid; ?>" value="<?php echo $name; ?>" class="checkbox" /><?php echo $name; ?></label></li>
                                                <?php
                                            }
                                            echo "</ul>";
                                        }
                                    }
                                    echo "</ul>";
                               
                                }
    Starting somewhere around line 67 (depending on your editor
     
  3. spoonboy90

    spoonboy90 Active Member

    Joined:
    Dec 20, 2012
    Messages:
    289
    Likes Received:
    28
    Location:
    Stoke-on-Trent, Staffordshire. UK
    and for the listing update dashboard form remove this code from

    /themes/geocrafttheme/library/controls/dashboard/dashboard_functions.php

    Code:
                                            <?php
                                                      $child = get_term_children($termid, CUSTOM_CAT_TYPE);
                                                      if ($child) {
                                                          echo "<ul class=\"children\">";
                                                          foreach ($child as $child_of) {
                                                              $term = get_term_by('id', $child_of, CUSTOM_CAT_TYPE);
                                                              $termid = $term->term_taxonomy_id;
                                                              $term_tax_id = $term->term_id;
                                                              $name = $term->name;
     
                                                              $catprice = $wpdb->get_row("select * from $wpdb->term_taxonomy tt ,$wpdb->terms t where tt.term_taxonomy_id='" . $term->term_taxonomy_id . "' and t.term_id = tt.term_id");
                                                              $cp = $catprice->term_price;
                                                              ?>
    <li><label><input class="list_category"  <?php
                                                    if (in_array($term_tax_id, $cates)) {
                                                        echo 'checked="checked"';
                                                    }
                                                    ?> type="checkbox" name="category[]" id="<?php echo $termid; ?>" value="<?php echo $name; ?>" class="checkbox" /><?php echo $name; ?></label></li>
                                                              <?php
                                                              $child = get_term_children($term_tax_id, CUSTOM_CAT_TYPE);
                                                              if ($child) {
                                                                  echo "<ul class=\"children\">";
                                                                  foreach ($child as $child_of) {
                                                                      $term = get_term_by('id', $child_of, CUSTOM_CAT_TYPE);
                                                                      $termid = $term->term_taxonomy_id;
                                                                      $term_tax_id = $term->term_id;
                                                                      $name = $term->name;
                                                                      $cate = get_term_children($term_tax_id, CUSTOM_CAT_TYPE);
                                                                      $catprice = $wpdb->get_row("select * from $wpdb->term_taxonomy tt ,$wpdb->terms t where tt.term_taxonomy_id='" . $term->term_taxonomy_id . "' and t.term_id = tt.term_id");
                                                                      $cp = $catprice->term_price;
                                                                      ?>
    <li><label><input class="list_category" <?php
                                                            if (in_array($term_tax_id, $cates)) {
                                                                echo 'checked="checked"';
                                                            }
                                                            ?> type="checkbox" name="category[]" id="<?php echo $termid; ?>" value="<?php echo $name; ?>" class="checkbox" /><?php echo $name; ?></label></li>
                                                                                                                            }
                                                                  echo "</ul>";
                                                              }
                                                          }
                                                          echo "</ul>";
                                                      }
    starting around line 924 (depending on your editor)
     

Share This Page