Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

render_featured_collection_category_selector()

Description

Render the featured collection category selector

Parameters

ColumnTypeDefaultDescription
$parent integer Parent collection ref
$context array Contextual data (e.g depth level to render or the current branch path)

Return

void

Location

include/render_functions.php lines 4178 to 4247

Definition

 
function render_featured_collection_category_selector(int $parent, array $context)
    {
    global 
$lang;

    
// If this information is missing, that's an unrecoverable error, the developer should really make sure this information is provided
    
$collection $context["collection"]; # as returned by get_collection()
    
$depth = (int) $context["depth"];
    
$current_branch_path $context["current_branch_path"]; # as returned by get_featured_collection_category_branch_by_leaf()
    
$modal = (isset($context["modal"]) && is_bool($context["modal"]) ? $context["modal"] : false);

    
$featured_collection_categories get_featured_collection_categories($parent, array());
    if(empty(
$featured_collection_categories))
        {
        return;
        }

    
$html_selector_name "selected_featured_collection_category_{$depth}";
    
$html_question_label_txt $lang["themecategory"] . ($depth == "" {$depth}");
    
?>
    <div class="Question">
        <label for=" echo $html_selector_name?>"> echo $html_question_label_txt?></label>
        
        $next_level_parent 
null;
        
?>
        <select id=" echo $html_selector_name?>" class="stdwidth" name=" echo $html_selector_name?>"
                onchange="featured_collection_category_select_onchange(this, document.getElementById('collectionform'));
                 echo ($modal "Modal" "CentralSpace"); ?>Post(document.getElementById('collectionform'));">                
            <option value="0"> echo $lang["select"]; ?></option>
        
        
// Allow user to move FC category to the root. Because we don't expose the collection type to the user, this will
        // give users the ability to convert between public collection and featured category at root level without access
        // to the collection type.
        
if($depth == 0)
            {
            
$dummy_root_lvl_selected = ($collection["type"] == COLLECTION_TYPE_FEATURED && $parent == "selected" "");
            
?>
            <option value="root"  echo $dummy_root_lvl_selected?>> echo $lang["featured_collection_root_category"]; ?></option>
            
            
}
        foreach(
$featured_collection_categories as $fc_category)
            {
            
// Never show as an option the FC you're editing
            
if($fc_category["ref"] == $collection["ref"])
                {
                continue;
                }

            
$html_attr_selected "";
            if(isset(
$current_branch_path[$depth]) && $fc_category["ref"] == $current_branch_path[$depth]["ref"])
                {
                
$html_attr_selected "selected";
                
$next_level_parent $fc_category["ref"];
                }
            
?>
            <option value=" echo $fc_category["ref"]; ?> echo $html_attr_selected?>> echo htmlspecialchars(i18n_get_translated($fc_category["name"])); ?></option>
            
            
}
            
?>
        </select>
        <div class="clearerleft"></div>
    </div>
    
    
if(is_null($next_level_parent))
        {
        return;
        }

    
$context["depth"] = ++$depth;
    return 
render_featured_collection_category_selector($next_level_parent$context);
    }

This article was last updated 18th January 2021 10:35 Europe/London time based on the source file dated 15th January 2021 10:50 Europe/London time.