kurt.farrar-mydigitalmedia.co
-
10/9/2008 5:47:18 PM
My tips with CMSMenu
Hi all,
I'm new to Kentico, having just signed up as a partner as I've a couple of clients interested in the products, and like for like I feel it's a superb tool, particularly for small businesses here in the UK (my target).
Anyway, I've been moving my own site over to Kentico, as I felt I couldn't really sell how good it is if I don't use it myself, and I ran into a few problems, which aren't really problems, but just weren't obvious to find the answers to. I tried searching DevNet and didn't find any related results, so I figured since I've worked out how to do what i want to do, I'll post my tips here for others to hopefully find if they're having the same problems.
How to add the CMSMenu control =====================
I found that the tutorial suggests that it's in the toolbox after adding CMS.Controls.DLL, but this isn't the case.The Control examples show how you can use this component, and it's actually located in CMSAdminControls, I assume its in the compiled dlls somewhere, but at least this exposes the component for me to use.
So add:
<%@ Register Src="~/CMSAdminControls/PageTitle.ascx" TagName="PageTitle" TagPrefix="cms" %>
to the top of your (master) page.
Then within your layout add:
<cms:CMSListMenu ID="Vertical" runat="server" HighlightedNodePath="/Home" CSSPrefix="Main;SubMenu;OtherSubMenus" FirstItemCssClass="first" LastItemCssClass="last" DisplayHighlightedItemAsLink="True" WhereCondition="NodeLevel = 1" />
Limiting the menu using the WhereCondition ============================
Next problem that I came across is that my menu was showing all levels of my pages within my site. I could exclude individual pages from the navigation by changing their individual properties, but I later found that this would exclude them from the breadcrumb control.
I had a look around for how to use the WhereCondition. Like the CMSMenu, I couldn't find anything on DevNet as to how to make full use of the WhereCondition, or even how to simply limit it to just the first level of pages.
I had a guess at the syntax and put Level = 0 (I figured I'd try zero based first and if it doesn't error then I'll nudge it up to 1). Anyway, it errored straight away, but thankfully the error message displayed the SQL Query that was being executed, I was able to run this, without my Level = 0 included and managed to browse through the available fields to find out where the level is specified. Eureka! I found it, and for anyone who's wanting to limit the levels here's how...
In the WhereCondition property of your CMSMenu control enter:
NodeLevel = 1 (for 1st level, amend to show other levels).
I hope that my 5 minutes of tips will be of some use to someone somewhere, and to the guys at Kentico, keep up to the good work.
Kurt Farrar Small Business IT Consultant
MyDigitalMedia kurt.farrar@mydigitalmedia.co.uk http://www.mydigitalmedia.co.uk
|