Hi all
This is really a question on best practices
Problem:
I have an itemtype: Contact
As one of the fields in this itemtype is a checkboxlist (called Areas) by which you can assign a contact to one or more company areas.
Now on one page of the site I would like to show all contacts belonging to area "X" and of course on another page contacts belonging to area "Y"
The obvious solution is using an Item publisher on each of these pages and filtering the itemlist before showing, which works just fine.
The filtering is done as follows:
var areaToShow= "1";
var contactList = GetLoop("ItemPublisher:Items.List").Where(e => e.GetString("ItemPublisher:Item.Areas").Split(',').Any(s => s == areaToShow));
Now this implies that I need a separate list template for each area, I would like to show. It would be much more handy, if I could set the area, which I want to show, in the backend.
I tried creating a new Item Type called ContactList with just one field: AreaToShow.
In the item template I can read this parameter and I can dynamically create an itempublisher listing contacts.
But what I can't figure out is how to transfer the parameter AreaToShow from the Item template to the itempublisher list template, and thus filtering the list by this parameter.
I guess you could register the paramter as a session variable, but that is not really what these are for.
You probably also could skip the itempublisher and do a db select instead.
Any input?
Best regards
Thomas