Make Header and Footer template visible only on the main page when using a MediaGalleryFileList

   —   
This article describes how to make Header and Footer template visible only on the main page with media files list – not on selected items. This code applies to MediaGalleryFileList control.
You could change the "SetupControl" code in the \CMSWebParts\MediaLibrary\MediaGalleryFileList.ascx.cs file to the following:

/// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (this.StopProcessing)
        {
            // Do nothing
        }
        else
        {
            int fid = QueryHelper.GetInteger(this.FileIDQueryStringKey, 0);
            if (fid > 0)
            {
                if (!String.IsNullOrEmpty(this.SelectedItemTransformationName))
                {
                    this.repItems.ItemTemplate = CMSDataProperties.LoadTransformation(this, this.SelectedItemTransformationName, false);
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(this.TransformationName))
                {
                    this.repItems.ItemTemplate = CMSDataProperties.LoadTransformation(this, this.TransformationName, false);
                }
               
                if (!String.IsNullOrEmpty(this.FooterTransformationName))
                {
                    this.repItems.FooterTemplate = CMSDataProperties.LoadTransformation(this, this.FooterTransformationName, false);
                }
                if (!String.IsNullOrEmpty(this.HeaderTransformationName))
                {
                    this.repItems.HeaderTemplate = CMSDataProperties.LoadTransformation(this, this.HeaderTransformationName, false);
                }
                if (!String.IsNullOrEmpty(this.SeparatorTransformationName))
                {
                    this.repItems.SeparatorTemplate = CMSDataProperties.LoadTransformation(this, this.SeparatorTransformationName, false);
                }                
            }
           

            this.repItems.DataBindByDefault = false;
            this.repItems.OnPageChanged += new EventHandler<EventArgs>(repItems_OnPageChanged);

            // Add repeater to the filter collection
            CMSControlsHelper.SetFilter(ValidationHelper.GetString
(this.GetValue("WebPartControlID"), this.ClientID), this.repItems);


            this.repItems.HideControlForZeroRows = this.HideControlForZeroRows;
            this.repItems.ZeroRowsText = this.ZeroRowsText;
        }
    }



See also:


Applies to: Kentico CMS 4.0
Share this article on   LinkedIn

Juraj Ondrus

Hi, I am the Technical support leader at Kentico. I'm here to help you use Kentico and get as much as possible out of it.