Developer forum

Forum » Templates » Best way to get items based on parameter?

Best way to get items based on parameter?

Sten Hougaard
Reply

Hi,

I need to get some items based content, which has been related to an ecom group. I have an item type where I have made a dropdown where the creator of the item can select which ecomgroup the item is related to (using a SQL query to pupulate the item list). So the editor creates paragraph items related to ecom groups.

On the page I  then need to get related items based on current ecom group name. I see more ways of doing this:

  • A Data list which will find items based on requested ecom group
  • A item publisher which will then filter out in the Loop the relevant items
  • Create a new "viewer item" which will then use the requested ecom group name to decide which items to publish.

My focus is on performance, easy copy from one soloution to another and flexibility.

Which pattern would you suggest that I use? Is there perhaps a "magic" Razor based pattern to retrieve items and the filter tem?


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

A: København/Aarhus . W: www.1stweb.dk
@: netsi1964


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Sten

I would suggest to use the publisher with a Razor template and filter out the items in the loop that should not be used. That would be fin in terms of performance as long as the number of items is relatively small, say under 500/page.

There are no buil-in search in the items API.

You can do a SQL that returns a list of paragraph items and call Content.Items.Queries.Repository.SelectByParagraphId with a list of the related paragraph ids

Nicolai

 
Sten Hougaard
Reply

Hi Nocolai,

Thank you for the reply.

So you would get a Loop and the have an IF sentence within the loop to test if a published item should be shown?

/Sten

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Yes!

Votes for this answer: 1

 

You must be logged in to post in the forum