Hi, when using a List Type, it is sometimes needed to have a field or variable that is shared across the items in the list. For example a list of products and one of the field is the price in a specific currency, where the conversion rate is stored in the DB.
Of course we can add a new field to the list that reads from the DB the rate but it's not efficient since it will make the exact same query for all the items in the list just to retrieve the same value.
So my question is: how to set up a value that can be referenced by all items in the list (excluding to put it in the URL that is not very nice)? I tried to add a field in the Search Form but it seems as fields in the List View cannot read values from the Search Form, am I wrong or is there any other method?
Thanks Bucklash for your kind reply. The use case is that calculation on result must use a variable taken outside of current content item.
Example: list of products where the price must be displayed in a specific currency; you can retrieve current exchange rate with a webservice call in PHP and you don't want to call that APIs as many times as many items are displayed in the list but do it once and then all items can access this "shared value".
Using JSession seems a good idea but how? With a Before Search field in the Search View and not in the List view (otherwise it will be invoked as many times as many items are in the list)?
Sorry for the late reply, but couldn't you use a BeforeRender field to load the fx rate into a variable? Then you could use this variable to convert the price into your target currency for each list item, I guess.
For the output in the list you could then use a php typo to convert the price just before it is rendered.