Developer forum

Forum » CMS - Standard features » Read properties from Column Item

Read properties from Column Item

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I have a situation where I need to access some properties of the Column Item in the template for ProductList feed.

I am basically trying to accomplish something similar with how the properties are read in the Printable papers setup but using a Column instead of a paragraph.

With regular paragraphs the properties are read using: Pageview.CurrentParagraph.Item["XXXXXX"]

I have looked in the API for the properties of PageView but I could not find something specific for "Columns" and from what I see in the database, Columns are basically Paragraphs.

Is there any other method for getting properties from the Column Item?

Thank you,
Adrian


Replies

 
Nicolai Pedersen
Reply

Since columns are a paragraphs - just in a specific location in a row marked by the ParagraphGridRowId specifying the id of the row, and the ParagraphGridRowColumn specifying the column index, you can access the the column/paragraph the same way using Pageview.CurrentParagraph.

You can currently not get the paragraphViewmodel for that column...

We are in the process of making the pageview and paragraph viewmodels available further down the stack so these things become easier. 

BR Nicolai

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you for your reply. I have realized that I could have tried in vain anyway since I was trying to read the values inside the feed template in the ProductCatalog module. I assume the feed rendering is always ignoring the Paragraph which means the paragraph object will always be null.

I will have to find another way.

Looking forward to the availability of paragraph view models.

Thank you,
Adrian

 
Nicolai Pedersen
Reply

Yes - you cannot do that. Feed=true is optimized to do one thing only as fast as possible. 

You can however call the same page, but not use feed=true and get the entire pageview stack and then gain access to the paragraph.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

I have realized that I won't be able to do that. Reading from the feed would have been pretty useful but I understand why it is not possible and never should be.

I am trying to implement a display of banners inside the product list and ideally, adding them to the JSON feed and indicating a different template for banners seemed the most efficient way to handle it.

I think I will have to go back to the drawing board :)

Thank you,

Adrian

 
Nicolai Pedersen
Reply

It sounds more like you need to alter your rendering instead of the data... You could have banners coming from a banners endpoint, and products from the content endpoint and then add logic to mix the rendering.

 

You must be logged in to post in the forum