Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Creating a Resume Categories widget

  1. #1
    Thread Starter
    Veteran koldsnapz's Avatar
    Join Date
    Mar 2011
    Location
    United States
    Posts
    402
    Thanks
    10
    Thanked 23 Times in 19 Posts

    Creating a Resume Categories widget

    Hello,

    I originally had my post in General Discussion but I feel that it is best suited here. I found it very surprising that Resume Categories were included, but no widget to sort through them was created as well.

    In theme-widgets.php I found the Job Categories code and tried to replicate it, but replacing Job with Resume where appropriate.

    Here is what I did:
    PHP Code:
    // the resume categories sidebar widget
    class JR_Widget_Resume_Categories extends WP_Widget {

        function JR_Widget_Resume_Categories() {
            $widget_ops = array( 'classname' => 'widget_resume_categories', 'description' => __( "A list or dropdown of resume categories", 'appthemes' ) );
            $this->WP_Widget('resume_categories', __('Resume Categories', 'appthemes'), $widget_ops);
        }

        function widget( $args, $instance ) {
            extract( $args );

            $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Resume Categories', 'appthemes' ) : $instance['title'], $instance, $this->id_base);
            $c = $instance['count'] ? '1' : '0';
            $h = $instance['hierarchical'] ? '1' : '0';
            $d = $instance['dropdown'] ? '1' : '0';

            echo $before_widget;
            if ( $title )
                echo $before_title . $title . $after_title;

            $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'taxonomy' => 'job_cat');

            if ( $d ) {
                $cat_args['show_option_none'] = __('Select Category', 'appthemes');
                wp_dropdown_categories(apply_filters('widget_resume_categories_dropdown_args', $cat_args));
    ?>

    <script type='text/javascript'>
    /* <![CDATA[ */
        var dropdown = document.getElementById("cat");
        function onCatChange() {
            if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
                location.href = "<?php echo home_url(); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
            }
        }
        dropdown.onchange = onCatChange;
    /* ]]> */
    </script>

    <?php
            
    } else {
    ?>
            <ul>
    <?php
            $cat_args
    ['title_li'] = '';
            
    wp_list_categories(apply_filters('widget_resume_categories_args'$cat_args));
    ?>
            </ul>
    <?php
            
    }

            echo 
    $after_widget;
        }

        function 
    update$new_instance$old_instance ) {
            
    $instance $old_instance;
            
    $instance['title'] = strip_tags($new_instance['title']);
            
    $instance['count'] = !empty($new_instance['count']) ? 0;
            
    $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 0;
            
    $instance['dropdown'] = !empty($new_instance['dropdown']) ? 0;

            return 
    $instance;
        }

        function 
    form$instance ) {
            
    //Defaults
            
    $instance wp_parse_args( (array) $instance, array( 'title' => '') );
            
    $title esc_attr$instance['title'] );
            
    $count = isset($instance['count']) ? (bool) $instance['count'] :false;
            
    $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
            
    $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
    ?>
            <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e'Title:' ); ?></label>
            <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title?>" /></p>

            <p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>"<?php checked$dropdown ); ?> />
            <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e'Show as dropdown' ); ?></label><br />

            <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked$count ); ?> />
            <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e'Show post counts' ); ?></label><br />

            <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked$hierarchical ); ?> />
            <label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e'Show hierarchy' ); ?></label></p>
    <?php
        
    }

    }
    Though I don't see this widget appear in my Widgets menu so I am guessing there is another step I am missing for writing it to the database. Any thoughts?

  2. #2
    Thread Starter
    Veteran koldsnapz's Avatar
    Join Date
    Mar 2011
    Location
    United States
    Posts
    402
    Thanks
    10
    Thanked 23 Times in 19 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  3. #3
    Thread Starter
    Veteran koldsnapz's Avatar
    Join Date
    Mar 2011
    Location
    United States
    Posts
    402
    Thanks
    10
    Thanked 23 Times in 19 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  4. #4
    Thread Starter
    Veteran koldsnapz's Avatar
    Join Date
    Mar 2011
    Location
    United States
    Posts
    402
    Thanks
    10
    Thanked 23 Times in 19 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  5. #5
    Thread Starter
    Veteran koldsnapz's Avatar
    Join Date
    Mar 2011
    Location
    United States
    Posts
    402
    Thanks
    10
    Thanked 23 Times in 19 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  6. #6
    Veteran luukratief's Avatar
    Join Date
    Apr 2011
    Posts
    250
    Thanks
    1
    Thanked 17 Times in 14 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  7. #7
    Thread Starter
    Veteran koldsnapz's Avatar
    Join Date
    Mar 2011
    Location
    United States
    Posts
    402
    Thanks
    10
    Thanked 23 Times in 19 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  8. #8
    tinygiantstudios's Avatar
    Join Date
    Jan 2011
    Posts
    1,607
    Thanks
    31
    Thanked 157 Times in 148 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!


  9. #9
    Thread Starter
    Veteran koldsnapz's Avatar
    Join Date
    Mar 2011
    Location
    United States
    Posts
    402
    Thanks
    10
    Thanked 23 Times in 19 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  10. #10
    tinygiantstudios's Avatar
    Join Date
    Jan 2011
    Posts
    1,607
    Thanks
    31
    Thanked 157 Times in 148 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!


Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. JR v1.4 Resume Categories
    By koldsnapz in forum JobRoller General Discussion
    Replies: 11
    Last Post: May 16th, 2011, 07:19 PM
  2. Replies: 2
    Last Post: October 12th, 2010, 08:36 AM
  3. Creating & Publishing Categories
    By royalstar in forum Report ClassiPress Bugs
    Replies: 6
    Last Post: September 19th, 2010, 02:20 PM
  4. More flexibility in creating categories and sub-categories
    By laura in forum ClassiPress General Discussion
    Replies: 4
    Last Post: April 26th, 2010, 10:18 AM