Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Communication between Web Parts View modes: 
User avatar
Member
Member
lancetek - 9/6/2011 4:25:02 PM
   
Communication between Web Parts
Hi,
I'm doing a page that has 3 regions for listing articles. The first region has the newest article (think headline article), the second region has a listing of 4 more articles that are the next newest, and the third region has a listing of the next 10 articles. So on this page we have a total of 17 Articles being listed, from newest at the top of the page to oldest at the bottom.

At first blush I thought I could use a single datasource to grab the 17 Articles, and then list them out using Repeaters... but I can't figure out how to split up the results of the datasource. And using 3 datasources often generate duplicate results, nevermind the performance of running 3 queries when one should do.

After fighting with this for a day, I ended up creating a custom web part that is actually most of the page, with 3 repeaters in the .ascx that are populated manually from the .ascx.cs - but this problem *feels* like something I should be able to do using the Kentico 'Lego' - some drag 'n drop and config, and not something that needs to be bodged by creating a custom Web Part.

Any ideas?

User avatar
Certified Developer 9
Certified Developer 9
charbf - 9/6/2011 9:34:23 PM
   
RE:Communication between Web Parts
you could do it with a single repeater and a single transformation.

Test the DataItemIndex if it's 3 and 7 you can close your first and second group

Lets say you have in on content before
<div class="groupone">

content after
</div>

at 3 you end your transformation with
</div>
<div class="grouptwo">


at 7 you end your transformation with
</div>
<div class="groupthree">

http://devnet.kentico.com/Knowledge-Base/Content-Management/Using-special-item-data-in-transformation.aspx

User avatar
Member
Member
lancetek - 9/7/2011 3:37:28 AM
   
RE:Communication between Web Parts
Thanks for pointing that out - but the 3 repeaters are on separate areas of the page, with different web parts in between them, so putting them in one repeater wouldn't work.

But you've given me an idea - I could try using the 3 repeaters, and only display items in it that meet the itemindex that I want.

I wonder if I will only get one sql call (group) to the database if I just use one datasource? Or if it will get called once per repeater?

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 9/7/2011 4:42:16 AM
   
RE:Communication between Web Parts
Hello,

The viewers working with a data source display the source and cannot restrict it. You can use a special transformation where it check the index and displays nothing if it does not meet a condition. Then you can use 3 viewer web parts with one data source and different transformations.

Otherwise I would recommend you to use 3 stand-alone web parts and set up a cache properly to restrict the database calls. You can use a Where condition for the second and third repeater like for example:

DocumentID NOT IN (Select TOP 3 DocumentID FROM ... )

More information about cache can be found here: Caching options and at Martin Hejtmanek's blog.

Best regards,
Helena Grulichova

User avatar
Member
Member
lancetek - 9/7/2011 7:23:50 AM
   
RE:Communication between Web Parts
Thanks for the response Helen.

Can the WHERE condition look into the content of another repeater? Or is it just SQL to run?

If it's just SQL, I got into some performance problems doing this:

query1 for first repeater
query2 where not in query1
query3 where not in query2 where not in query1

query1 ran quickly.
query2 ran ok, but query1 has now been run twice - once for the initial query and now as a subquery
query3 ran very slowly for reasons explained in query2

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 9/7/2011 8:16:51 AM
   
RE:Communication between Web Parts
Hello,


The Where condition can contain macros and its format meets standard SQL.

You can also use the standard ASP.NET repeaters and data sources to execute the query one time, parse the data sets and bind them to the particular controls. Kentico CMS do not have any default tools which could help you in this case in my opinion.


Best regards,
Helena Grulichova