D
D
danil_linkins2017-11-15 11:04:19
MODX
danil_linkins, 2017-11-15 11:04:19

Is it possible to pass data between snippets in MODx?

The thing is, let's say I display a price table on the site, and I have one connection to the database, from where I pull out an array of data and display the price I need.
When all this is in one snippet, and it has to be called for each price value. then this whole process with connecting to the database and the data in the array happens every time. Of course, the session quickly goes beyond the allowable memory limit and the server returns an error.
Tell me, please, how can I solve this problem so that once I connect to the database and take the data, and then just display them everywhere? Any other solution is possible, as long as the site does not fall =)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2017-11-15
Nekhamkin @SergeN

Try using a cached snippet call.
When generating a page, it will be executed only once, even if it is called many times in the template code.
For more details, for example, here you can read https://itchief.ru/lessons/modx-revo/modx-caching

D
DarWiM, 2017-11-23
@DarWiM

Just in case, I'll leave this link about caching.
Programmatic (Custom) Caching

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question