ASPX templates
Version 5.x > ASPX templates > A Transformation Within A Transformation? View modes: 
User avatar
Member
Member
Daljo628 - 10/19/2010 1:56:29 PM
   
A Transformation Within A Transformation?
Not to sound overly like Hamlet or anything (play within a play), but here's my current difficulty:

Background:
In our current site build, we are going to be displaying products in a catalog format. As they aren't actually selling any products through the site, we have been working off of a custom document type, rather than actual commerce functionality within Kentico.

Three of the fields that we are using in our custom document type (RelatedProducts, CoordinatingProducts, and Upgrades) will hold a comma-seperated list of SKU codes. What I need to do is take those SKU codes, and display the 'Products' (Documents) that have that (unique) SKU code, via either a transformation or fixed bit of code.

Question In Brief:
In a custom function called by a transformation for {Document A}, does Kentico offer any way to return some content from a different document (of the same type), {Document B}, that is specified within a field in {Document A}? Ideally, the returned content would be {Document B}, formatted according to a pre-selected transformation for its document type, but it could simply return the values to the function, to be formatted there.

User avatar
Member
Member
kentico_michal - 10/26/2010 3:48:57 AM
   
RE:A Transformation Within A Transformation?
Hi,

It depends on relationship beetwen these two documents. I suppose you want to get Document B based on some field value of Document A. As a input value of a custom function you could use that field value and in function it would be a matter of custom query:

I will give you simple example. Let's say I want to get document node of some news document as per its NewsSummary value (field value).

1. Select record from news coupled data table (CONTENT_news in this case) where NewsSummary column contains requested value.

2. Get NewsID value (it is used as foreign key in CMS_Document table).

3. Select record from CMS_Document table, where DocumentForeighKeyValue = NewsID.

So finally, the query could look like this following one

Select DocumentName from CMS_Document Where DocumentForeignKeyValue = (SELECT NewsID FROM CONTENT_news WHERE NewsTitle LIKE 'fieldValue')

4. Now you have record for your document and you can get its DocumentID and use CMS.TreeEngine.TreeProvider.SelectSingleDocument(Int32) method.

Please take a look at API reference to find more information http://devnet.kentico.com/downloads/kenticocms_api.zip

The problem is that you need to know the document type in this case, so that you could specify name of the coupled_table (in this case CONTENT_news).

Anyway, there is also DocumentNodeID field in CMS_Document table, that equals to NodeID in CMS_Tree table. Then you can get NodeClassID from CMS_Tree, that refers to ClassID field in CMS_Class. CMS_Class table also contains ClassTableName field which contains the identification of table where data are stored (etc. CONTENT_news).
So, this way you can get the information about document type and table where related data are stored.

Best regards,
Michal Legen