osc_count_subcategories()

osc_count_subcategories()

Gets the total of subcategories for the current category. If subcategories are not loaded, this function will load them and. it will prepare the the pointer to the first element

Code osc_count_subcategories():


    function osc_count_subcategories() {
        $category = View::newInstance()->_current('categories');
        if ( $category == '' ) return -1;
        if ( !isset($category['categories']) ) return 0;
        if ( !is_array($category['categories']) ) return 0;
        if ( count($category['categories']) == 0 ) return 0;
        if ( !View::newInstance()->_exists('subcategories') ) {
            View::newInstance()->_exportVariableToView('subcategories', $category['categories']);
        }
        return osc_priv_count_subcategories();
    }

    /**
     *
     * @return int
     */