Determine Logic of a Custom Macro

Paul Turner asked on August 29, 2022 19:00

Hello,

We have a custom table customtable_webshareTopics which contains topic categories for shares submitted on our site about pages they are viewing. There is a macro (CurrentDocument.ShareTopic) that retrieves the topic category for a page when it is being displayed. That enables the correct shares to be shown on the page. The macro appears to be pulling the topic category for the page from the customtable_webshareTopics table.

We need to be able to pull the topic category for a page from a different application (one that can’t call the macro) and are trying to understand how the macro is associating the page (CMS_Document table?) and the topic in the customtable_webshareTopics table.

We’ve used SQL Management Studio to create a visual map of the relationships in the database but it doesn’t not make any connctions to the customtable_webshareTopics table.

Does anyone have any suggestion on how to determine how the relationship is made?

Thanks,

Paul

Correct Answer

Juraj Ondrus answered on September 1, 2022 05:29

The DocumentForeignKeyValue column holds the ID value of the coupled data table - the table specific for your page type.

So, the field is indeed using the Custom table item selector - this means, that the editors are selecting an item from a custom table in this field. So, this is the "relation" to the custom table. And the macro CurrentDocument.ShareTopic is just a default macro - you can use it for any page field like CurrentMacro.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Juraj Ondrus answered on August 30, 2022 14:03

There is no relation between the pages tabled and custom tables. Unless it was customized - you should check your project documentation. The "CurrentDocument.ShareTopic" macro or this format is usually used to get values from a page type field - isn't it possible that given page type has the "ShareTopic" field set and this field is maybe custom table item selector?

0 votesVote for this answer Mark as a Correct answer

Paul Turner answered on August 31, 2022 02:32

Thanks for your response, Juraj. Unfortunately, the DocumentType column is NULL for all pages. Unfortunately, there is no project documentation for this. I'll keep digging and see if I can figure out where the code that resolves ShareTopic resides. It would clearly show how the relationship is being made. I've searched the filesystem but haven't found any references to that string. The search goes on... :-)

Thanks again.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on August 31, 2022 05:47

Do you mean the column in the coupled data table? Or what column you mean? So there is a field called ShareTopic defined for the page type? If yes, what is its data type and what form control is used for this field?

0 votesVote for this answer Mark as a Correct answer

Paul Turner answered on August 31, 2022 15:36

The CMS_Document table has a column named DocumentType. That's the column I'm referring to. All of the values in that column are NULL. I don't see any other "type"-related columns or tables. There are CMS_DocumentTag, CMS_DocumentTypeScope, and CMS_DocumentTypeScopeClass but they are all empty.

If I'm misunderstanding that you're describing as "page type", please tell me. Thanks for your help.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on August 31, 2022 15:53

The documentType column is a system column to tell the type of the document - in this case when using CMS.File page type it stores the value of the file's extension to set the header disposition correctly. Please, see the pages database structure. There is the Coupled data table which stores the values from the Form/Content tab - the page type fields.
When you go to the page types, edit the page type - what is the definition of the ShareTopic field?

0 votesVote for this answer Mark as a Correct answer

Paul Turner answered on August 31, 2022 16:19

Thanks for your patience. I'm still getting familiar with Kentico. I did find a ShareTopic for the page type. Here is what is displayed: ........... Field name: ShareTopic Data type: Text Size: 400 Required: No Default Value: None Translate field: No Field caption: Share Topic Field description: None Explanation field: None Form control: Custom table item selector Custom table: Web Share Topics (customtable_webshareTopics Format of the display name: {%Description%} ({%Topic%}) Name of the value column: Topic

The rest of the fields are blank. ..........

Please tell me if this answers the question you asked.

I've started reading the page you reference.

0 votesVote for this answer Mark as a Correct answer

Paul Turner answered on August 31, 2022 16:36

pages database structure says:

Records in the coupled data tables are bound to pages through the DocumentForeignKeyValue column of the CMS_Document table.

Do you know which table and column the DocumentForeignKeyValue column maps to? I searched the NodeID column of CMS_Tree with the DocumentForeignKeyValue for a page and CMS_Document but they didn't appear to match. It seems that the DocumentNodeID column in CMS_Document maps to NodeID in CMS_Tree.

0 votesVote for this answer Mark as a Correct answer

Paul Turner answered on September 1, 2022 13:39

Thank you, Juraj. You helped me find the table that holds the ShareTopics. I sincerely appreciate your help!

1 votesVote for this answer Mark as a Correct answer

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