Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

render_featured_collection()

Description

Render a featured collection (as tiles on the collections_featured.php page)

Parameters

ColumnTypeDefaultDescription
$ctx array Context data to allow caller code to decide rendering requirements
$fc array Featured collection data structure

Return

void

Location

include/render_functions.php lines 4986 to 5162

Definition

 
function render_featured_collection(array $ctx, array $fc)
{
    if(empty(
$fc))
        {
        return;
        }

    global 
$baseurl_short$lang$flag_new_themes$flag_new_themes_age$view_title_field$FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS;

    
$is_smart_featured_collection = (isset($ctx["smart"]) ? (bool) $ctx["smart"] : false);
    
$general_url_params = (isset($ctx["general_url_params"]) && is_array($ctx["general_url_params"]) ? $ctx["general_url_params"] : array());
    
$show_resources_count = (isset($ctx["show_resources_count"]) ? (bool) $ctx["show_resources_count"] : false);
    
$reorder = (bool) ($ctx['reorder'] ?? false);

    
$html_container_class = array("FeaturedSimpleTile""HomePanel");
    
$html_container_data_items = [];

    
// Make featured collection tile sortable
    
if($reorder && !$is_smart_featured_collection)
        {
        
$html_container_class[] = 'SortableItem';
        
$html_container_data_items['data-fc-ref'] = $fc['ref'];
        }

    
// Set main featured collection URL (e.g for collections it's the !collection[ID], for categories it's for collection_featured.php)
    
$html_fc_a_href generateURL("{$baseurl_short}pages/search.php"$general_url_params, array("search" => "!collection{$fc["ref"]}"));
    
$html_fc_a_href = (isset($ctx["href"]) && trim($ctx["href"]) !== "" $ctx["href"] : $html_fc_a_href);

    
$fc_display_name strip_prefix_chars(i18n_get_collection_name($fc),"*");

    
$html_contents_h2 $fc_display_name;
    
$counter_html "";
    if (
        !
$is_smart_featured_collection 
        
&& $flag_new_themes 
        
&& (time() - strtotime((string)$fc["created"])) < (60 60 24 $flag_new_themes_age)
        && !
$show_resources_count
    
) {
        
$counter_html "<p class=\"tile_corner_box\">" escape($lang['newflag']) . "</p>";
    } elseif (
$show_resources_count && !is_anonymous_user() && !is_authenticated()) {
        
$counter_html "<p data-tag=\"resources_count\" 
                            data-fc-ref=\"
{$fc['ref']}\"
                            class=\"tile_corner_box\">" 
escape($lang['counting_resources']) . "</p>";
    }

    
$theme_images = (isset($ctx["images"]) ? $ctx["images"] : array());
    
$theme_images array_map(
        function(
$theme_image) use ($view_title_field$lang){
            if (!
is_array($theme_image)) {
                return 
null;
            }
            if (!isset(
$theme_image['ref'])) {
                return 
$theme_image// Invalid data [t35944]
            
}
            
$ref $theme_image['ref'];
            
$resource_data get_resource_data($ref);
            if (
$resource_data===false) {
                return 
$theme_image;
            }
            
$theme_image['alt_text'] = $resource_data['field' $view_title_field] ?? $lang['resource-1'] . ' ' $ref;
            return 
$theme_image;
        }
    , 
$theme_images);

    
$html_container_data '';
    foreach(
$html_container_data_items as $name => $value)
        {
        
$html_container_data .= sprintf(' %s="%s"'$nameescape($value));
        }

    
$tools = (isset($ctx["tools"]) && is_array($ctx["tools"]) ? $ctx["tools"] : array());

    if (
        isset(
$fc['thumbnail_selection_method']) 
        && 
$fc['thumbnail_selection_method'] == $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS['most_popular_images']
    ) {
        
$theme_images array_pad($theme_images3null);
    }

    if (
count($theme_images) == 1) {
        if (
$theme_images[0] == null) {
            
$image_html "<div class=\"tile-placeholder\">
                                <div class=\"thumbs-tile-image\"></div>
                           </div>"
;
        } else {
            
$image_html sprintf("<img class=\"thmbs-tile-img\" src=\"%s\" alt=\"%s\">"
                        
$theme_images[0]['path'], escape($theme_images[0]['alt_text'] ?? ""));
        }
    } elseif (
count($theme_images) >= 3) {
        if (
$theme_images[0] == null) {
            
$image_html "<div class=\"tile-placeholder\">
                                <div class=\"thumbs-tile-image\"></div>
                           </div>
                           <div class=\"tile-sub-multi\">
                               <div></div>
                               <div></div>
                           </div> 
                           "
;
        } else {
            
$image_html sprintf("<img class=\"thmbs-tile-img\" src=\"%s\" alt=\"%s\">"
            
$theme_images[0]['path'], escape($theme_images[0]['alt_text'] ?? ""));
            
$image_html .= "<div class=\"tile-sub-multi\">";
            
$image_html .= $theme_images[1] == null 
                
"<div></div>" 
                
sprintf("<img class=\"thmbs-tile-img\" src=\"%s\" alt=\"%s\">"$theme_images[1]['path'], escape($theme_images[1]['alt_text'] ?? ""));
            
$image_html .= $theme_images[2] == null 
                
"<div></div>" 
                
sprintf("<img class=\"thmbs-tile-img\" src=\"%s\" alt=\"%s\">"$theme_images[2]['path'], escape($theme_images[2]['alt_text'] ?? ""));
            
$image_html .= "</div>";
        }
        
        
$image_html sprintf("<div class=\"tile-multi\">%s</div>"$image_html);
    } else {
        
$image_html "<div class=\"tile-placeholder\">
                           <div class=\"thumbs-tile-image\"></div>
                       </div>"
;
    }

    
// DEVELOPER NOTE: anything past this point should be set. All logic is handled above
    
?>
    <a class=" echo implode(' '$html_container_class); ?>
    href=" echo $html_fc_a_href?>
    onclick="return CentralSpaceLoad(this, true);" 
    id="FeaturedSimpleTile_ echo md5($fc['ref']); ?>"
     echo $html_container_data?> >
        <div 
        class="HomePanel featured-tile"
        href=" echo $html_fc_a_href?>
        onclick="return CentralSpaceLoad(this, true);" 
        id="featured_tile_ echo md5($fc['ref']); ?>"
         echo $html_container_data?>
        >
            
            
echo $image_html;
            
?>
            <div class="tile-desc">
                <h2> echo $html_contents_h2?></h2>
                
                render_top_right_menu_btn
($tools);
                
?>
            </div>
             echo $counter_html?>
        </div>
        
        render_featured_collection_context_menu
(md5($fc['ref']), $tools);
        
?>
    </a>
    <script>
        jQuery(document).ready(function() {
            var fctilename = "#FeaturedSimpleTile_ echo md5($fc["ref"]); ?>";
            var tilehref; //Used to switch off and on tile link to stop issue clicking on tool bar but opening tile link
            var tileonclick; //Used to switch off and on tile link to stop issue clicking on tool bar but opening tile link

            var fcactionsid = ".top-right-menu > i";

            jQuery(`${fctilename} ${fcactionsid}, # echo md5($fc['ref']); ?>`).hover(
                function(e) {
                    tilehref = jQuery(fctilename).attr("href");
                    tileonclick = jQuery(fctilename).attr("onclick");
                    jQuery(fctilename).attr("href", "#");
                    jQuery(fctilename).attr("onclick", "return false;");

                    jQuery(`a.FeaturedSimpleTile:not(${fctilename})`).css('pointer-events', 'none')
                },
                function(e) {
                    jQuery(fctilename).attr("href", tilehref);
                    jQuery(fctilename).attr("onclick", tileonclick);
                    tilehref = '';
                    tileonclick = '';

                    jQuery(`a.FeaturedSimpleTile:not(fctilename)`).css('pointer-events', 'initial')
                }
            );
        })
    </script>  
    
}

This article was last updated 6th June 2026 21:35 Europe/London time based on the source file dated 4th June 2026 10:35 Europe/London time.