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

You must configure the container to supply this value

July 11, 2012    Author: Joel

In implementing Microsoft Enterprise Library 5.0 – Data Access Application Block

I got this error:

The type Database cannot be constructed. You must configure the container to supply this value.

at line:  Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>();

Turned out I forgot to add the Provider Name to the connection string:

providerName=”System.Data.SqlClient”

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