M
M
Maxim2018-09-14 02:04:31
Yii
Maxim, 2018-09-14 02:04:31

Yii2 How to correctly implement pjax of the entire site?

Hello. In principle, I know how to work with pjax, there is nothing complicated about it. At least with part of the code. However, I want to translate the entire site template to pjax so that the pages load without reloading the page.
The blocks are placed like this. Menu on the left, content in the center and widgets on the right. Everything is standard.
Tell me, is there any point in pushing the whole site into pjax? Is pjax generally used this way, or is it more for other purposes? Where should it be inserted in order to be correct and what is the best way to do it using such a template?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Novikov, 2018-09-14
@myks92

First of all, when such a question arises, it is worth asking - why do this at all?
But let's leave this question hanging in the air, let's answer the questions.
Specifically in pjax - no. Yii pjax is a tool for wrapping a single widget to make it work over ajax. This is noticeable even by the full class name - yii\widgets\Pjax That is, in order for the entire site to work through pjax, you need to pervert and make it all - one widget, albeit with others built into it. Routing such a widget will be your initial nightmare, because the stock Yiishny is not ready for this - and should not
If you want to go, not checkers, then to make a Single page application, use the appropriate technology for this. React, Angular, Vue - the whole world of modern front-end is at your service. Yes, you won’t be able to do it with regular Yii tools, and you won’t upgrade in Pjax, but you will get experience in writing Api in Yii (with which SPA will work) and a full-fledged front-end.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question