Blog
Get Url to Original Document of a Linked Document in Kentico
October 4, 2012 Author: Joel
Lets say you have a linked document that is rendered on a landing page.
You want the user to click through to the original document though, not to the linked document.
Here is a simple function you can add to your MyFunctions to be used in your transformation.
public static string GetOriginalDocUrl(int nodeLinkedNodeID)
{
CMS.TreeEngine.TreeProvider tp = new CMS.TreeEngine.TreeProvider(CMS.CMSHelper.CMSContext.CurrentUser);
CMS.TreeEngine.TreeNode node = tp.SelectSingleNode(nodeLinkedNodeID);
return CMS.CMSHelper.CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath, CMSContext.CurrentSiteName);
}
Then when calling it from your transformation:
<a href='<%# MyFunctions.GetOriginalDocUrl(Eval<int>("NodeLinkedNodeID")) %>'>Original Document</a>
Document does not exist in Kentico CMS content tree
August 29, 2012 Author: Joel
Today I got an error when clicking on a document in the content tree. Document does not exist.

We believe the table for the documents data was some how deleted in a Sql Server degradation.
In any event Kentico CMS still had record of these documents to be displayed in the tree. I was unable to delete these documents from the content tree in the UI.
In order to delete them from the content tree I had to go directly into the database and remove the records for the documents in the CMS_Tree and CMS_Document table.
First find the reference to the document in the CMS_Tree table:
SELECT [NodeID], [NodeClassID]
FROM [your_db_name].[dbo].[CMS_Tree] WHERE nodealiaspath LIKE ‘%[the alias path]%’
Now you can take the NodeId and look it up in the CMS_Document table:
SELECT *
FROM [your_db_name].[dbo].[CMS_Document] WHERE DocumentNodeId = [the NodeId from the previous query]
If this exist delete this record first and then delete the record from the CMS_Tree table.
Kentico CMS Nested repeaters with dynamic path
August 9, 2012 Author: Joel
If you have a nested repeater where you want the path of it to be dynamic based on the current document you can’t do this inline. You need to create a script block and define it in there.
For example in the transformation of the top level repeater:
<script runat="server">
protected override void OnInit(EventArgs e) {
repProducts.Path = String.Format("{0}/%", Eval("NodeAliasPath"));
repProducts.ReloadData(true);
}
</script>
<cms:CMSRepeater ID="repProducts" runat="server" ClassNames="cms.product" OrderBy="NodeLevel,NodeOrder" SelectOnlyPublished="true" SelectTopN="5" TransformationName="cms.Product.Preview" MaxRelativeLevel="1" />
Kentico – SelectNodes (Documents) API
June 19, 2012 Author: Joel
Here is a an easy way to select all documents under a given node in the document tree using the API. In this example I am getting all the documents under the parents parent of the current document.
CMS.SiteProvider.UserInfo ui = CMS.SiteProvider.UserInfoProvider.GetUserInfo("administrator");
CMS.TreeEngine.TreeProvider tree = new CMS.TreeEngine.TreeProvider(ui);
String aliasPath = CMS.CMSHelper.CMSContext.CurrentDocument.Parent.Parent.NodeAliasPath + "/%";
DataSet ds = tree.SelectNodes("[your site name]", aliasPath, "en-us", true, "[the class name you're looking for]");
Dropdown menu in Kentico with cmslistmenu
April 9, 2010 Author: Joel
Scenerio: I wanted to created a drop down menu with the cmslistmenu instead of the cmsmenu control. The cmsmenu control works, but the rendered output is a LOT of tables and javascript. I like to keep my markup as lean as possible. I also wanted to use a cms control so the menu could be built dynamically at runtime based on the cms content structure.
Solution: The solution is actually quite simple and you’ll see that you can cut and paste most of this to work with your project.
1. Drop the <cms:CMSListMenu ID=”CMSListMenu1″ runat=”server” /> control in your markup where you want the menu to be rendered.
2. Updated your css stylesheet for the site.
#CMSListMenu1{margin:0; list-style:none;}
#CMSListMenu1 li.CMSListMenuLI, #CMSListMenu1 li.CMSListMenuHighlightedLI{float:left; font-size:13px; font-weight:bolder; line-height:30px; text-transform:uppercase; padding-right:22px;}
#CMSListMenu1 li.CMSListMenuLI ul{position:absolute; display:none; width:13em; background-color:#000; padding:0 0 6px 4px; list-style:none;}
#CMSListMenu1 li.CMSListMenuLI:hover ul{display:block;}
#CMSListMenu1 li.CMSListMenuHighlightedLI ul{position:absolute; display:none; width:13em; background-color:#000; padding:0 0 6px 4px; list-style:none;}
#CMSListMenu1 li.CMSListMenuHighlightedLI:hover ul{display:block;}
#CMSListMenu1 li.CMSListMenuLI ul.CMSListMenuUL li.CMSListMenuLI, .nav li.CMSListMenuHighlightedLI ul.CMSListMenuUL li.CMSListMenuLI{float:none; line-height: 2em;}
#CMSListMenu1 li.CMSListMenuLI ul.CMSListMenuUL li.CMSListMenuHighlightedLI{float:none; line-height: 2em;}
#CMSListMenu1 li.CMSListMenuLI ul.CMSListMenuUL li.CMSListMenuHighlightedLI .CMSListMenuLinkHighlighted{color:#006600;} #CMSListMenu1 li a, #CMSListMenu1 li a:visited{color:#9e7c13; text-decoration:none;}
#CMSListMenu1 li a:hover{color:#006600;}
These two steps along will give you a working dropdown menu. Now simply update they styling in your stylesheet to match your site.
3 (optional): If you care about IE6 you’re going to have to add a little jQuery to get the dropdown to function.
3a. Add jQuery reference in the head of your site if you’re not already using it:
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
*note I like to advantage of the MS CDN.
3b. I add a javascript reference to a globals javascript file.
<script src="~/Scripts/global.js" type="text/javascript"></script>
In that globals.js file add these lines of code:
$(document).ready(function() {
$('li.CMSListMenuLI, li.CMSListMenuHighlightedLI').hover(
function() { $('ul', this).css('display', 'block'); },
function() { $('ul', this).css('display', 'none'); });
});
Working example: Nature Valley Pro Ride
You may have to create an IE conditional style sheet to fix the positioning of the dropdowns.
That’s it, a simple way to get a dropdown menu based on your cms content that is semantically correct using pure css and a little jQuery for IE6.
-
Categories
- asp.net (13)
- Blog (3)
- Business (6)
- Conferences (1)
- Errors (7)
- Office (1)
- Portfolio (3)
- Reviews (3)
- SEO (4)
- SQL Server (4)
- Tips (2)
- Uncategorized (3)
- Web Development (18)
-
Archives
- October 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- January 2012
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- April 2009
- March 2009