Examine Syntax problem with search results macro file
Using Umbraco 7, I hace setup a macroscript partial. It seems to work fine, however if I have a "metaDescription" for a returned result that is null, then the macro doesn't render correctly and gives an error.
If the results all have metaDescriptions then all is good, but I need to add an if statement or some logic to let the results to not display that field if Null or no value...All the various if statement syntax I try don't seem to work though..Any ideas?
Thanks!
@inherits umbraco.MacroEngines.DynamicNodeContext
@using Examine;
@using UmbracoExamine;
@*get the search term from the querystring*@
@{var searchTerm = Request.QueryString["search"];}
@{var pageResults = ExamineManager.Instance.SearchProviderCollection["MySiteSearcher"].Search(searchTerm, true);}
<div class="container" style="margin-bottom:50px;">
<div class="row">
<h1>Search Results</h1>
</div>
<div style=" font-family: 'UniversLTW01-47LightCn',sans-serif; font-size: 30px;">search results for <strong>"@searchTerm"</strong></div>
@if (
@pageResults.TotalItemCount == 0
)
{
<div role="alert" class="alert alert-warning">
<strong>no results found matching "@searchTerm"</strong><br/>
<br/>
<ul>
<li>Make sure all words are spelled correctly</li>
<li>Try diferent keywords</li>
<li>try more general keywords</li>
</ul>
</div>
}
<div>
@*PAGES*@
<div>
@if (@pageResults.TotalItemCount > 0)
{
<div id="PAGE" class="assetCatHeader">pages</div>
}
@*TODO: FILTER OUT UMBRACONAVIHIDEPAGES*@
@foreach (var page in pageResults) {
<div class="[email protected]["umbracoNaviHide"]">
<div style="width:50px;float:left;"><span style="font-size:40px;"></span></div>
<dl>
<dt>
<a href="@umbraco.library.NiceUrl(page.Id)">@page.Fields["ghxPageTitle"]</a></dt>
@*PROBLEM OCCURS HERE*@
<dd>@page.Fields["metaDescription"]</dd>
</dl>
</div>
}
</div>
</div>
</div>
Examine Syntax problem with search results macro file
Using Umbraco 7, I hace setup a macroscript partial. It seems to work fine, however if I have a "metaDescription" for a returned result that is null, then the macro doesn't render correctly and gives an error.
If the results all have metaDescriptions then all is good, but I need to add an if statement or some logic to let the results to not display that field if Null or no value...All the various if statement syntax I try don't seem to work though..Any ideas?
Thanks!
Let me know if I'm leaving out any pertinent information. thanks again
is working on a reply...