I've got a piece of code in a widget which I would like to change from a list of links of the category into a drop down list instead. The code is below:
function widget_category_list($args)
{
global $wpdb, $wpdir;
$data = get_option('wpdir_Widget');
$query = "select * from " . $wpdb->prefix . "wpdir_category cat, " . $wpdb->prefix . "wpdir_category_path path where cat.category_id = path.category_id and cat.parent_id = 0 and cat.visible = 1 order by cat.name asc limit " . $data['cat_limit'];
$content = $wpdb->get_results($query);
echo $args['before_widget'];
echo $args['before_title'];
echo $data['cat_title'];
echo $args['after_title'];
echo "<ul>";
$counter = 0;
foreach($content as $data)
{
echo "<li";
if ($counter % 2 == 0){ echo " class='alternate_cell'"; }
echo ">";
echo "<a href=\"".$wpdir->config['url_permalink']."/".$data->path_with_slash."\">";
echo $data->name. " (" . $data->number_link . ")";
echo "</a>";
echo "</li>";
$counter ++;
}
echo "</ul>";
echo $args['after_widget'];
}
function register()
{
register_sidebar_widget('WPDIR Category List', array('wpdir_Widget', 'widget_category_list'));
register_widget_control('WPDIR Category List', array('wpdir_Widget', 'control_widget_category_list'));
}
}
Would really appreciate some help...
Cheers,
-William
function widget_category_list($args)
{
global $wpdb, $wpdir;
$data = get_option('wpdir_Widget');
$query = "select * from " . $wpdb->prefix . "wpdir_category cat, " . $wpdb->prefix . "wpdir_category_path path where cat.category_id = path.category_id and cat.parent_id = 0 and cat.visible = 1 order by cat.name asc limit " . $data['cat_limit'];
$content = $wpdb->get_results($query);
echo $args['before_widget'];
echo $args['before_title'];
echo $data['cat_title'];
echo $args['after_title'];
echo "<ul>";
$counter = 0;
foreach($content as $data)
{
echo "<li";
if ($counter % 2 == 0){ echo " class='alternate_cell'"; }
echo ">";
echo "<a href=\"".$wpdir->config['url_permalink']."/".$data->path_with_slash."\">";
echo $data->name. " (" . $data->number_link . ")";
echo "</a>";
echo "</li>";
$counter ++;
}
echo "</ul>";
echo $args['after_widget'];
}
function register()
{
register_sidebar_widget('WPDIR Category List', array('wpdir_Widget', 'widget_category_list'));
register_widget_control('WPDIR Category List', array('wpdir_Widget', 'control_widget_category_list'));
}
}
Would really appreciate some help...
Cheers,
-William