Updated 051 Dynamic Router Implementation Explained (markdown)

Amigo 2019-09-04 12:07:18 +02:00
parent 1c3515ac49
commit 85e3d47667
1 changed files with 7 additions and 4 deletions

@ -63,16 +63,19 @@ The first one is Sermon (series id). In Custom Script scroll down to the bottom,
[00:11:56](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m56s)
JCB's Dynamic Build changed 'sview' value to Sermon instead of leaving it the same. There is a very good reason for that. Usually, this would be the correct response but in this case, it was not. (Due to its complexity, I am not going to explain it), so you want these two values to be the same and it is the site view's name. We could just save it close. <<<<<<<
JCB's Dynamic Build changed 'sview' value to Sermon instead of leaving it the same. There is a very good reason for that. Usually, this would be the correct response but in this case, it was not. (Due to its complexity, I am not going to explain it), so you want these two values to be the same and it is the site view's name. We could just save it close.
### Sermon (Preacher id)
The next one we want to do is Sermon (Preacher id). It was also [00:12:25](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m25s) having the same issue. We are going to do the same kind of just add the custom option to ensure that these two values remain the same.
The next one we are going to do is Sermon (Preacher id). [00:12:25](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m25s) It was also having the same issue. We are going to just add the Custom option to ensure that these two values remain the same.
### Resolving Category
[00:10:39](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m39s)
[00:12:39](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m39s)
Then last but not least was this category. It is also behaving incorrectly and it's only because it [00:12:47](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m47s) didn't detect that this is a category. That is primarily because it is using the Sermon table to start instead in the Sermon table we have a Joint here to category it does load the category. [00:13:12](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m12s) In the Tweak you will see that we are using JRequest ID, and this is a category ID. It should go look for the category and build the parse method based on the category. In Custom Script we are also going to add [00:13:33](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m33s) a true to this getVar, which tells the getVar method that this is a category. This name in effect is going to be ignored. Because it's 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. We can save and close. [00:13:59](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m59s)
Last but not least is the Category that behaves incorrectly and it is only because it did not detect that this is a category. [00:12:47](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m47s) That is primarily because it is using the Sermon table to start instead. In the Sermon table, we have a Joint here to the category that loads the category. [00:13:12](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m12s) <<<<<<<<<<<
In the Tweak you will see that we are using (JRequest) ID, and this is a category ID. It should go look for the category and build the parse method based on the category. In Custom Script we are also going to add [00:13:33](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m33s) a true to this getVar, which tells the getVar method that this is a category. This name in effect is going to be ignored. Because it's 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. We can 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. We see here that 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) It seems to me that we already have a very workable situation and this is going to make it so much better. There was also the idea of adding some custom scripting into the built method. We will look at that and I invite you and anyone else to get involved in this on GitHub. If you know how to improve his even more then 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've done so far. But like alliterative developing concepts we will continue improving this to the point where it serves as well and holds up with changes also happening in Joomla itself.