This site uses cookies and similar technologies.

If you don't change browser settings, you agree to it.

I understand
231 Posts
Giuse
2 months ago
6
Topic

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 a lot!

Giuse

Get a Book for SEBLOD
231 Posts
Giuse
2 months ago
0
Level 1

Hi, anyone has an idea?

thanks

Giuse

231 Posts
Giuse
1 month ago
0
Level 1

Hi, one last request if there is a solution for this, then I will stop bumping and bothering :)

thanks a lot

Giuse

1207 Posts
Bucklash
1 month ago
3
Level 1

I haven’t got a clue what you are trying to do but what about jsession?

If want to render list items but apply a calculation on result of each item then be javascript, no?

231 Posts
Giuse
1 month ago
2
Level 2

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)?

cheers

Giuse

1207 Posts
Bucklash
1 month ago
0
Level 3

Sorry Giuse

I do not know.... 

40 Posts
RatingAction
1 month ago
0
Level 3

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.

Get a Book for SEBLOD