Hide Placeholder- contensis
// Small collection of basic custom code (VB) snippets for Contensis
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
// code for collapsing a placeholder based on whether there are subtemplates or text inside it.
if Control.controls.count = 0 andalso (value = "" OrElse value= "[add mini-templates here]") then
sideColumn.visible = false
mainColumn.attributes("class")= mainColumn.attributes("class") & " sys_col1-expanded"
response.write("hide")
else
response.write("has controls")
end if
exit sub
///### THis first one works ###///
If Control.controls.count = 0 then
If value.trim.toLower.indexof("[add … here]") > -1 Or StripHTML(HttpUtility.HTMLDecode(value).trim).length = 0 Or StripHTML(value).trim() = " " then
Control.Parent.visible = false
End If
End If
If Control.controls.count = 0 then
If value.trim.toLower.indexof("[add content here]") > -1 Or StripHTML(HttpUtility.HTMLDecode(value).trim).length = 0 then
Control.visible = false
End If
End If
If Control.controls.count = 0 then
If value.indexof("<img") = -1 then
If StripHTML(HttpUtility.HTMLDecode(value).trim).length = 0 then
Control.visible = false
Else
If value.trim.toLower.indexof("insert a link") > -1 then
Control.visible = false
End If
End If
End If
End If
------------------------------------------------------------------------------------------------
// code for hiding divs (set div to runat="server" first!)
{name of div ID here}.visible = false
------------------------------------------------------------------------------------------------
//Code for adding Javascript files
//Jquery
Utilities.RegisterJquery
//jQuery R8
AppContext.Current.Page.Scripts.RegisterJQuery()
//r6
Utilities.RegisterJavaScriptFile("/SiteElements/Scripts/tabbox.js")
//R7.2
CurrentContext.Page.Scripts.Add("/SiteElements/Scripts/checkbox.js")
//Add javascript just before the closing body tag
Javascript.StartUpJavascriptFiles.Add("/SiteElements/Scripts/flexslider.js")
//Code for adding stylesheets in custom code
CurrentContext.Page.CSS.Add("/SiteElements/Stylesheets/550-structuredContent.css")
------------------------------------------------------------------------------------------------
// If statement based on current page id
if me.ContentId {= < > etc} 1 then
[do something]
end if
//for example;
if me.ContentId <> 1 then
TitleBar.text = TitleBar.text & " -Page Title"
end if
** "else" and "elseif" can also be used. Not is done by using "if not"
------------------------------------------------------------------------------------------------
'Add conditional CSS files to head
ContensisHeader.Text += "<!--[if lte IE 7]>" & Environment.Newline
ContensisHeader.Text += "<link rel=""stylesheet"" type=""text/css"" href=""/SiteElements/Styles/901-ie7.css"" />" & Environment.Newline
ContensisHeader.Text += "<![endif]-->" & Environment.Newline
ContensisHeader.Text += "<!--[if lte IE 9]>" & Environment.Newline
ContensisHeader.Text += "<script type=""text/javascript"" src=""SiteElements/Javascript/compat.js""></script>" & Environment.Newline
ContensisHeader.Text += "<![endif]-->" & Environment.Newline
// Text in footer?
FooterLit.Text = "<scr" & "ipt type=""text/javascript"" src=""/SiteElements/Javascripts/fixpng.js""></scr" & "ipt><noscript>Warning: png images may not display correctly as your browser does not support JavaScript.</noscript>"
-------------------------------------------------------------------------------------------------
'Add responsive meta tag thingy
ContensisHeader.Text += "<meta name=""viewport"" content=""width=device-width, initial-scale=1"">" & Environment.Newline
-------------------------------------------------------------------------------------------------
// Custom code for manual filtering of controls (where 'featureList' = control ID)
//declare variable
Dim SectionFolderID As Integer
//Define the variable
SectionFolderID = CMS_API.Utilities.NavigationXMLHelper.Instance.GetFolderParentForLevel(Property_F_ID,2)
'Business Growth Zone
If SectionFolderID = 18526
//Filter if you're in this folder and MD_Zones contains 'Business Growth Zone' and also it's image is empty
Dim DataFilter As New CMS_API.Data.DataFilterExpression("", CMS_API.Data.DataFilterFunction.Custom, "(MD_Zones LIKE 'Business Growth Zone' AND PROPERTY_ImageUrl = '')")
FeatureList.DataFilters.Add(DataFilter)
'response.write("Business Growth")
'Enterprise Zone
Else If SectionFolderID = 18528
Dim DataFilter As New CMS_API.Data.DataFilterExpression("", CMS_API.Data.DataFilterFunction.Custom, "(MD_Zones LIKE 'Enterprise Zone' AND PROPERTY_ImageUrl = '')")
FeatureList.DataFilters.Add(DataFilter)
'response.write("Enterprise ")
'Business Relocation Zone / Inward Investment
Else If SectionFolderID = 18527
Dim DataFilter As New CMS_API.Data.DataFilterExpression("", CMS_API.Data.DataFilterFunction.Custom, "(MD_Zones LIKE 'Inward Investment Zone' AND PROPERTY_ImageUrl = '')")
FeatureList.DataFilters.Add(DataFilter)
'response.write("Business Relocation")
'Welcome Zone
Else If SectionFolderID = 18514
Dim DataFilter As New CMS_API.Data.DataFilterExpression("", CMS_API.Data.DataFilterFunction.Custom, "PROPERTY_ImageUrl = ''")
FeatureList.DataFilters.Add(DataFilter)
'response.write("Welcome")
End If
// Set global filter to OR - needed for featured news control
FeatureList.DataFilters.LogicalOperator = 2
// Filter featured news control to display items without an image
'FeatureList.DataFilters.Add(New DataFilterExpression("", CMS_API.Data.DataFilterFunction.Custom,"PROPERTY_ImageUrl = ''"))
// USE a VARIABLE in the filter
'FeatureList.DataFilters.Add(New DataFilterExpression("", CMS_API.Data.DataFilterFunction.Custom,"PROPERTY_ImageUrl = " & variableName & ""))
// LANGUAGE Selection
'Customised Language Toggle Link
Dim contentId As Integer = Property_c_id
Dim url As String = ""
'Try
'If on en page
' If Property_PageLanguageId = 1 Then
' LanguageToggleHyperlink.Text = "Cymraeg"
' Dim navProvider As CMS_API.Navigation.NavigationProvider = CMS_API.Navigation.NavigationProviderFactory.GetNavigationProvider(CMS_API.Navigation.NavigationProviderType.Xml)
' Dim navContent As CMS_API.Navigation.INavigationContent = CType(navProvider.GetItemByDatabaseID(contentId, CMS_API.Navigation.NavigationItemTypes.Webpage), CMS_API.Navigation.INavigationContent)
' if navContent.SlaveNavigationContentList.count > 0 then
' url = navContent.SlaveNavigationContentList(0).Url
'response.write(url)
' LanguageToggleHyperlink.NavigateUrl = url
' end if
' Else If Property_PageLanguageId = 8 Then
' LanguageToggleHyperlink.Text = "English"
' Dim navXmlHelper As CMS_API.Utilities.NavigationXMLHelper = CMS_API.Utilities.NavigationXMLHelper.Instance
' Dim xmlId As String = navXmlHelper.GetElementXmlId(contentId, CMS_API.Utilities.NavigationXMLHelper.MenuType.pageitem)
' Dim masterContentID As Integer = navXmlHelper.GetElementMasterContentId(xmlId)
' url = System.Web.HttpUtility.HtmlEncode(CMS_API.Utilities.NavigationXMLHelper.Instance.GetPagePath(masterContentID))
' LanguageToggleHyperlink.NavigateUrl = url
'Search redirect
' SearchQueryControl.resultsurlwebpageid = 23522
' End If
'Catch Ex As Exception
'Toggle link uses default setting and goes to cy homepage
'End Try
//RAZOR STUFF!
//Get query string value as var;
Dim quizIdent = Request.QueryString("YourVarHere")
//Set query string in URL
< href="url/pagename.aspx?@YourVarHere">blah</a>
// Replace
dim folderName = quizResult.QuizName.Replace(" ", "_")
//Using razor vars in urls / src's etc;
<img class="sys_qCardIcon" src="/SiteElements/Images/quizresults/icons/@folderName/@(nameStrength)_@(nameIconS).png" alt="@strength.Name" title="@strength.Name"/>
DEBUGGING!
System.Diagnostics.Debugger.Break();
// Razor listing with pagination for structured Content
@using Contensis.Framework.Web;
@using Contensis.Framework.Web.Search;
@using System.Xml;
@using System.ServiceModel.Syndication;
@using System.Web.Mvc;
@{
var kbQuery = Query.Where("SC_T_ID").IsEqualTo("-806");
var kbItems = new NodeFinder().Find(kbQuery);
var utils = new CMS_API.Common.BaseUtilities();
int kbCount = kbItems.Count;
int currentPage = 1;
int itemsPerPage = 4;
int endIndex = 0;
int startIndex = 0;
if (Request.QueryString.Count > 0) {
currentPage = Convert.ToInt32(Request.QueryString["page"]);
} else {
currentPage = 1;
}
if (currentPage > 1)
{
startIndex = ((currentPage - 1) * itemsPerPage);
if ((kbCount > itemsPerPage) && ((currentPage * itemsPerPage) <= kbCount)) {
endIndex = (currentPage * itemsPerPage);
} else {
endIndex = kbCount;
}
}
int pageCount = (kbCount + itemsPerPage - 1) / itemsPerPage;
}
<div id="Listing_List" class="sys_datarepeatercontrol">
<div class="sys_itemslist sys_kb">
@foreach (var kbItem in kbItems.Skip(startIndex).Take(itemsPerPage))
{
var description = kbItem.Data.Description.ToString();
var SourceType = kbItem.Data.SourceType;
var Title = kbItem.Data.Title;
var Publisher = kbItem.Data.Publisher;
var GeographicalScope = kbItem.Data.GeographicalScope;
<div class="sys_subitem sys_kbItem">
<div class="sys_boxWrap">
<div class="sys_shadowWrap sys_kbInner">
<h2><a href="@kbItem.Path" title="@Title">@Title</a></h2>
<p>@description</p>
<ul>
<li><strong>Publisher: @Publisher</strong></li>
<li><strong>Geographical scope: @GeographicalScope</strong></li>
<li><strong>Type: @SourceType</strong></li>
</ul>
<p><a class="sys_button" title="Read more" href="@kbItem.Path"> Read More </a></p>
</div>
</div>
</div>
}
</div>
</div>
@{
int paginationStart = currentPage - 5;
int paginationEnd = paginationStart + 10;
if (kbCount > itemsPerPage) {
if (paginationStart < 1) {
paginationStart = 1;
}
if (paginationEnd > pageCount) {
paginationEnd = pageCount;
}
}
}
<div class="sys_flickrpager">
<div class="sys_navigation">
@if (currentPage > 1) {
<span class="sys_navigationprevious"><a title="Go to the previous page" href="?page=@((currentPage - 1))">Previous</a></span>
} else {
<span class="sys_navigationprevious sys_disabled"><span>Previous</span></span>
}
@for (int i = paginationStart; i < (paginationEnd + 1); i++) {
if (i == currentPage) {
<span class="sys_page sys_selected"><span>@i</span></span>
} else {
<span class="sys_page"><a title="Go to page @i" href="?page=@(i)">@i</a></span>
}
}
@if (currentPage <= 1) {
<span class="sys_navigationnext"><a title="Go to the next page" href="?page=@((currentPage + 1))">Next</a></span>
} else {
<span class="sys_navigationnext sys_disabled"><span>Next</span></span>
}
</div>
</div>
// IIS GZIP, CACHING & EXPIRES HEADERS
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseExpires" httpExpires="Tue, 19 Jan 2038 03:14:07 GMT" />
</staticContent>
<httpCompression directory="%SystemDrive%\inetpubtemp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>
/// switching contentFinder to show different textfiles based on folder id (twitter on pearson schools)
// adds it to a new div called twitterDiv
dim cf as new ContentFinder
cf.contentTypeId = "13"
cf.id = "twitterCF"
if Property_TopFolderID = 36049 then ' secondary
cf.contentName = "twitterSecondary"
elseif Property_TopFolderID = 36339 then ' feandvocational
cf.contentName = "twitterFE"
end if
twitterDiv.controls.add(cf)
'redirect stuff
if CurrentNode.Data.MD_Redirect.ToString().Length > 0 then
Dim redirectURL as string = md_redirect
if redirectURL = "" then
'do nothing
else
Page.Response.StatusCode = 301
Page.Response.Redirect(redirectURL)
end if
else
end if