Hello!
Note: This ain't a perfect solution. I spend some time testing but there may be bugs...
1. Open oc-content/themes/bender/functions.php
2. Paste this at the bottom of the file, but before ?>.
function wm_category_select_only_lowest($categories = null, $item = null, $default_item = null) {
// Did user select a specific category to post in?
$catId = Params::getParam('catId');
if(Session::newInstance()->_getForm('catId') != "") {
$catId = Session::newInstance()->_getForm('catId');
}
if($categories == null) {
if(View::newInstance()->_exists('categories')) {
$categories = View::newInstance()->_get('categories');
} else {
$categories = osc_get_categories();
}
}
if ($item == null) { $item = osc_item(); }
echo '<select name="catId" id="catId">';
if(isset($default_item)) {
echo '<option value="">' . $default_item . '</option>';
} else {
echo '<option value="">' . __('Select a category') . '</option>';
}
foreach($categories as $c) {
if(isset($c['categories']) && is_array($c['categories']) && count($c['categories'])) {
echo '<optgroup label="' . $c['s_name'] . '">';
wm_subcategory_select_only_lowest($c['categories'], $item, $default_item, 1);
echo '</optgroup>';
} else {
$selected = ( (isset($item["fk_i_category_id"]) && $item["fk_i_category_id"] == $c['pk_i_id']) || (isset($catId) && $catId == $c['pk_i_id']) );
echo '<option value="' . $c['pk_i_id'] . '"' . ($selected ? ' selected="selected"' : '' ). '>' . $c['s_name'] . '</option>';
}
}
echo '</select>';
return true;
}
function wm_subcategory_select_only_lowest($categories, $item, $default_item = null, $deep = 0) {
// Did user select a specific category to post in?
$catId = Params::getParam('catId');
if(Session::newInstance()->_getForm('catId') != ""){
$catId = Session::newInstance()->_getForm('catId');
}
// How many indents to add?
$deep_string = "";
for($var = 0;$var<$deep;$var++) {
$deep_string .= ' ';
}
$deep++;
foreach($categories as $c) {
$selected = ( (isset($item["fk_i_category_id"]) && $item["fk_i_category_id"] == $c['pk_i_id']) || (isset($catId) && $catId == $c['pk_i_id']) );
if(isset($c['categories']) && is_array($c['categories']) && count($c['categories'])) {
echo '<optgroup label="' . $deep_string . $c['s_name'] . '">';
wm_subcategory_select_only_lowest($c['categories'], $item, $default_item, $deep);
echo '</optgroup>';
} else {
echo '<option value="' . $c['pk_i_id'] . '"' . ($selected ? ' selected="selected'.$item["fk_i_category_id"].'"' : '') . '>' . $deep_string . $c['s_name'] . '</option>';
}
}
}
3. Open oc-content/themes/bender/item-post.php
4. Find <?php ItemForm::category_select(null, null, __('Select a category', 'bender')); ?>
5. Replace with <?php wm_category_select_only_lowest(null, null, __('Select a category', 'bender')); ?>
6. Enjoy.
Regards.