Updated 051 Dynamic Router Implementation Explained (markdown)

Amigo 2019-09-04 15:41:00 +02:00
parent 5d523f811e
commit cab3bd6ce2
1 changed files with 9 additions and 3 deletions

@ -51,13 +51,17 @@ To illustrate this within the JCB interface. With this new dynamic implementatio
[00:08:19](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m19s)
Let us return to the interface to show where the changes can be made to have the `category` rendered correctly as well as the `preacher` and the `series`. Basically, make the changes so that `sermon` will say `series`, and this one will say `true`, and this one `preacher` would also say, `preacher`.[00:08:48](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m48s) That is all that needs to be done and the router will work without any errors. Here in the interface, are the Site Views that need to be changed, which are Preacher, Series, and Category. [00:09:15](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m15s) If Preacher is opened, you will see that it has a Dynamic Get called 'Sermons' (preacher id) and it is a (getListQuery). This is the one that should be changed. [00:09:35](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m35s) The Dynamic Get, as well as Series', the same applies to that. There are Sermons (series id) (getListQuery) that also need to change. It is not changed in the view. The idea was that if it gets changed in the Dynamic Get it will automatically write the correct code to whatever view is added because we have added some Custom Placeholders within the script.
Let us return to the interface to show where the changes can be made to have the `category` rendered correctly as well as the `preacher` and the `series`. Basically, make the changes so that `sermon` will say `series`, and this one will say `true`, and this one `preacher` would also say, `preacher`.[00:08:48](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m48s)
That is all that needs to be done and the router will work without any errors. Here in the interface, are the Site Views that need to be changed, which are Preacher, Series, and Category. [00:09:15](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m15s) If Preacher is opened, you will see that it has a Dynamic Get called 'Sermons' (preacher id) and it is a (getListQuery). This is the one that should be changed. [00:09:35](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m35s) The Dynamic Get, as well as Series', the same applies to that. There are Sermons (series id) (getListQuery) that also need to change. It is not changed in the view. The idea was that if it gets changed in the Dynamic Get it will automatically write the correct code to whatever view is added because we have added some Custom Placeholders within the script.
### Sermon (series id) - Heads Up For Placeholders
[00:10:06](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m06s)
The first one is Sermon (series id). In Custom Script scroll down to the bottom, there is a new tab option here, Add PHP (parse Method)-in Router'. [00:10:29](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m29s) Click 'Yes', and it will dynamically load what can be considered the most basic implementation of that short snippet. It looks very familiar, it got these placeholders. It has a specific sview placeholder because we are dealing with the Site View and it has to have this 's' in it to replace it with the site view name. [00:10:55](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m55s) So wherever this is going to be used, this Dynamic Get would be replaced with that specific site view's value. That is to give a heads up about the placeholder and that is what makes it dynamic, that you can use it in any site view and it will automatically write this because the display of the page is based on the database request which is built in the URL by the name of the view as well as the ID of the element. If multiple variables are being passed [00:11:32](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m32s) to the URL, you can update that and replace multiple values. In this one, the default option will resolve the issue because remember these two values were not the same.
The first one is Sermon (series id). In Custom Script scroll down to the bottom, there is a new tab option here, Add PHP (parse Method)-in Router'. [00:10:29](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m29s) Click 'Yes', and it will dynamically load what can be considered the most basic implementation of that short snippet. It looks very familiar, it got these placeholders. It has a specific sview placeholder because we are dealing with the Site View and it has to have this 's' in it to replace it with the site view name. [00:10:55](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m55s)
So wherever this is going to be used, this Dynamic Get would be replaced with that specific site view's value. That is to give a heads up about the placeholder and that is what makes it dynamic, that you can use it in any site view and it will automatically write this because the display of the page is based on the database request which is built in the URL by the name of the view as well as the ID of the element. If multiple variables are being passed [00:11:32](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m32s) to the URL, you can update that and replace multiple values. In this one, the default option will resolve the issue because remember these two values were not the same.
### JCB Change sview to sermon
@ -77,4 +81,6 @@ Last but not least is the Category that behaves incorrectly and it is only becau
In the Tweak, the (JRequest) ID is used, and this is a category ID. It should go and look for the category and build the parse method based on the category. In Custom Script we are also going to add a 'true' to this getVar, which tells the getVar method that this is a category. [00:13:33](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m33s) This name in effect is going to be ignored because it is not going to look for the value of this table, it is going to the category table and look for the value there. This will resolve this issue. Save and close. [00:13:59](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m59s)
Now we have done some customization to our Router just by adding those values to the Dynamic Get. If we compile our component now, it will automatically fall back to those values. Just install it again. [00:14:21](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m21s) Let's go look at the code. It did exactly what we wanted, it added `preacher` there. This category is `true`, and we see the series is `series`. At least we know that the router will behave correctly. This is the first step of our improvement to the router. [00:14:49](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m49s) There was also the idea of adding some custom scripting into the built method. We will look at that and I invite you to get involved in this on GitHub. If you know how to improve this, please [00:15:16](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m16s) get in contact with me and let's work together. This is what we have done so far. But like alliterative developing concepts we will continue improving this to the point where it serves us well and holds up with changes in Joomla.
Now we have done some customization to our Router just by adding those values to the Dynamic Get. If we compile our component now, it will automatically fall back to those values. Just install it again. [00:14:21](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m21s) Let's go look at the code. It did exactly what we wanted, it added `preacher` there. This category is `true`, and we see the series is `series`. At least we know that the router will behave correctly. This is the first step of our improvement to the router. [00:14:49](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m49s)
There was also the idea of adding some custom scripting into the built method. We will look at that and I invite you to get involved in this on GitHub. If you know how to improve this, please [00:15:16](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m16s) get in contact with me and let's work together. This is what we have done so far. But like alliterative developing concepts we will continue improving this to the point where it serves us well and holds up with changes in Joomla.