call today Call Today 320.281.0605

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>
Share

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.

Share

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" />

Share

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]");
Share

Dropdown menu in Kentico with cmslistmenu

April 9, 2010    Author: Joel

dropdownmenu

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.

Share
Agent Cody Banks 2 Destination London full lenght movie download Afghan Knights download movie Inside the Smiths download movie Beverly Hills Chihuahua download movie Permanent Vacation download movie Indiana Jones and the Kingdom of the Crystal Skull download movie Afghan Knights download movie Inside the Smiths download movie Beverly Hills Chihuahua download movie Permanent Vacation download movie Indiana Jones and the Kingdom of the Crystal Skull download movie