S
S
siroper2022-04-07 15:01:11
MODX
siroper, 2022-04-07 15:01:11

How to generate pages automatically in modx?

Using the API, we get certain cities, villages, and even streets. Displaying something through a snippet on a specific page is not a problem in terms of php.
For example, we displayed the list of required cities via API via a snippet, php , etc. at site.ru/cities/ .

But now the task is to ensure that when moving to a city, town, etc. from this page, information was displayed on the API of this particular city (for example , site.ru/cities/Belgorod ), without manually creating the Belgorod page itself, respectively. The information is dynamic, so it makes no physical sense to create and save pages.

Those. in fact, it is functionally similar to site.ru/cities?city=Belgorod where in PHP we get the value - Belgorod, we check it through the API for authenticity and display information.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Danny Arty, 2022-04-07
@siroper

It is possible to accept a get-parameter on the site.ru/cities/ page , conditionally city with the name of the city, for example site.ru/cities?city=Belgorod . Another snippet is to get the value of this get-parameter and, accordingly, display information about the desired city.
And in order for the url to have an appropriate look, this can already be solved using htaccess, so that the user sees the url like site.ru/cities/Belgorod instead of site.ru/cities?city=Belgorod

A
Anton Tarasov, 2022-04-07
@an-tar

First of all, here on the Toaster it is customary to mark the decision if it was useful.
On this issue, you can create a plugin for the OnPageNotFound event and then make your own forwarding to any page with parameters, and it will already render what you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question