Sitecore Multilist with Search
Usually when using Sitecore Multilist with search, it returns all the versions of the item, I can use the following extra condition to the Filter parameter: StartSearchLocation=<ITEM_ID>&Filter=_latestversion:true
This will result to show only the latest version of the item.
Toggle place holders based on Sitecore page mode
Sometimes we want to show the generic callouts in Page Editor mode but we don’t want to show the callout wrapper if there is no callouts being set in Sitecore.
Let’s say we have the following html:
<div class=“module-three-column”>
<div class=“module-three-column-box”>
<sc:Placeholder ID=“phCallout1” runat=“server” Key=“Left Single Row Callout” />
</div>
<div class=“module-seperator”></div>
<div class=“module-three-column-box”>
<sc:Placeholder ID=“phCallout2” runat=“server” Key=“Center Single Row Callout” />
</div>
<div class=“module-seperator”></div>
<div class=“module-three-column-box”>
<sc:Placeholder ID=“phCallout3” runat=“server” Key=“Right Single Row Callout” />
</div>
</div>
I don’t want to show this control at all if any of the placeholders don’t have controls.
Here is the code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!Sitecore.Context.PageMode.IsPageEditor)
{
if (!phCallout1.HasControls() && !phCallout2.HasControls() && !phCallout3.HasControls())
{
this.Visible = false;
}
}
}
I just check to if this is not page editor mode then I check if any of the placeholders has any controls, if not don’t display the control in the front end.
It works like a charm.