Create Custom Module for admin UI

Sayer Aljohani asked on September 30, 2020 15:46

Hi, I have list of articles that created as type page, I want to dispaly some of them based on speciefic value. This should be shown like my disk app in admin dasboard, when user clicks on it should dispaly list of filtered articles. I try to use Custom Module without creating classes becouse I will use kentico API to render articles in gridview. However, the Module not listed in admin page. Could you please guid me how to implment this requirment? Thank you.

Recent Answers


Brenden Kehren answered on September 30, 2020 16:07

In your custom module, you'll create a new User Interface. You should not need to use any custom code to do this since these are already classes in Kentico. You can simply navigate to the new UI element you've created and on the General tab, set the Element content type to a Page template and select the template of Object Listing. Save the page.

Next, go to the Properties tab. Set the Object type to Page (cms.document). You'll have to set the Grid definition path to a location on your server's disk. This would be something like /App_Data/CMSModules/<modulename>/UI/Grids/<objecttype>/default.xml. Once you have that grid definition in place you'd set the Where condition of your listing to ClassName == 'cms.article' or whatever your classname is for your page type.

This should get you the basic listing. Now if you want to add that page to your dashboard, simply navigate to that UI page (wherever you placed it in the Kentico menu/UI) and click the pin in the upper navigation.

1 votesVote for this answer Mark as a Correct answer

Sayer Aljohani answered on October 1, 2020 13:06

Thank for your answer. Almost solved my problem. However, I am using MVC custom development, so I created page type called Article then I moved generated code in new MVC project. How can I select data from this class? I tried to below code but none of them work: 1. use namespace instead of cms

<grid>
<objecttype  name="namespace.article" columns="ArticleID, Title" />
<!--<query name="namespace_Article" columns="ArticleID, Title" ></query>-->
</grid>
  1. Use table name direct in objecttype

    <objecttype name="namespace_article" columns="ArticleID, Title"

  2. Query: <query name="namespace_Article" columns="ArticleID, Title"/>

Note: I did not create class for this module becouse I do not need to store any data, only view list of articles in grid then user can click on edit action to open Page in tree

Thank you.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on October 3, 2020 14:17

Abad, your answer will only work for a custom class. Sayar is working with a page type.

Sayar, the "namespace" is the code name of the page type.

0 votesVote for this answer Mark as a Correct answer

Sayer Aljohani answered on October 4, 2020 08:22 (last edited on October 4, 2020 08:23)

Thank for you all. Yes. the namespace is same as in code, also it is registed in class_table in DB, but still kentico not fetch data. However, I think I need to create a method to select data direct from database and then map it to grid. Is there any suggestion how to do that?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on October 4, 2020 15:26

Sayar, you may have to use cms.document as your object and filter it in the where condition by classname = 'cms.article'

1 votesVote for this answer Mark as a Correct answer

Sayer Aljohani answered on October 4, 2020 16:22 (last edited on October 4, 2020 16:26)

Thank you. This only filter documents based on class type, but I want to fillter by fields of Article class. How can I display articles in grid and then filtter the data. It seems that Kentico only render built-in object such as cms.user, cms.document. I want render this query in grid insted of defualt object type:

 select * from CMS_Document inner join MyNamespace_Article on ArticleID = DocumentForeignKeyValue and MyNamespace_Article.Priority ='Low'

All the best.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on October 4, 2020 16:55

Your query should look like this:

select * from view_cms_tree_joined inner join MyNamespace_Article on ArticleID = DocumentForeignKeyValue and MyNamespace_Article.Priority ='Low'
Where classname = 'mynamespace.article'

Using the CMS.document object type allows you to get the necessary page and node details. Using the view I referenced joining the article table allows you to get the referenced page type data.

Just be sure you use the proper grid definition for an object type OR a query, not both.

0 votesVote for this answer Mark as a Correct answer

Sayer Aljohani answered on October 5, 2020 07:22

Thank you. How can I pass these conditions from Kentico, is there any API that creates inner join between cms.document and mynamespace.article? Would you mind if you provide an example for passing page type list to grid ? becouse I tried many ways but none of them works.

0 votesVote for this answer Mark as a Correct answer

Mohamad Ramadan answered on October 6, 2020 10:50

Dear Brenden

we used this query on page type and pass it to the UniGrid on the Query attribute when loading the module interface it gives us an error

Message: [SqlHelper.ValidatePagedQuery]: The paged query 'SaudiPedia.Article.GetOutdated' cannot be executed without the orderBy set.

the Query is

select [ClassName], [ClassDisplayName], [DocumentModifiedWhen], [NodeID], [NodeSiteID], [DocumentCulture], [DocumentName], [DocumentNamePath] from view_cms_tree_joined inner join SaudiPedia_Article on ArticleID = DocumentForeignKeyValue and SaudiPedia_Article.ArticleUpdateNotificationDate <= GETDATE()
Where classname = 'SaudiPedia.Article' ORDER BY [DocumentName] ASC
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.