API Questions on Kentico API.
Version 6.x > API > Teaser Image for Event Entry/News View modes: 
User avatar
Member
Member
brendan-ignitedcoder - 10/10/2012 2:06:09 AM
   
Teaser Image for Event Entry/News
Hi Guys,

I have successfully queried the top 3 events from the CONTENT_Events table but my client needs to show a teaser image for each event. I was using MVC before but that proved to be a little trickier than expected so I've switched to Web Parts/ASCX files instead. I need to do the following if possible.

1. Add a field to upload a teaser image for an event entry
2. Read this image and display it on the page
3. Get the teaser image used for a news item and display it also.

And lastly, can anyone suggest the SQL for reading the top 5 news items, and also how do I make a news item and an event featured items. Perhaps a flag in the DB to indicate the item as featured??

Thanks in advance,

Brendan

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/10/2012 5:17:15 AM
   
RE:Teaser Image for Event Entry/News
Hi,

you can modify (add fields) to the default news and event (or booking event) document types.

You just go to the Site Manager - Development - Document types - <document type> - Fields and add:

1. File field (Direct uploader)
2. Boolean field, use a checkbox control for example to ensure featured functionality.

Then you should see these new fields on the Form tab in the CMS Desk.

Now to select for example top 5 event documents, you can use a standard repeater web part and define it properties:
Path: /%
Document type: cms.event //or other code name of document type
Transformation: select some transformation.
Top N: 5


To display image in the transformation you can use code:

<%# GetImage("ImageFieldName") %>

As for Featured checkbox. Based on boolean value you can display text:

<%# (Eval<bool>("BlogPostAllowCommentsOrAnotherBooleanField")==true)?"Featured":"Not featured"%>

Best regards,
Ivana Tomanickova



User avatar
Member
Member
brendan-ignitedcoder - 10/14/2012 8:07:07 AM
   
RE:Teaser Image for Event Entry/News
Hi Avana,

Thank You for your help, this is really helpful since I've struggled to find cohesive docs to point me at this... I have another question if you don't mind.

1. I've moved from using MVC to a ASCX file but it would seem I don't need any of these as I can just use a standard repeater.
2. If I do use a standard repeater, how will I change it to use a UL/LI tag and what layout possibilities exist? For example I want to show it as follows

[ ]
[ img ]
Date: event date
Summary: Event Summary
[HREF] to event.

I would similarly like to setup a custom display for the event details page and possibly include comments etc.

Any suggestions.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/16/2012 6:45:43 AM
   
RE:Teaser Image for Event Entry/News
Hi,

if you use a standard repeater (ascx) or better our repeater web part, you can simply write transformation with <ul> <li> elements. They will be resolved. In properties of web part you can find Content bofere and Conent after property. The code inserted in these properties will be used to wrap code generated by transformation.

As for comments. You can issert message board web part to the template. The comments added via this web part are connected with the document. It means that comments can be unique on each document.

Best regards,
Ivana Tomanickova