Updated 051 Dynamic Router Implementation Explained (markdown)
parent
1c9d7c1853
commit
f0584176ac
@ -31,21 +31,21 @@ Open` router.php`. There is a function called '`build`', a class method as well
|
|||||||
|
|
||||||
If we look at `preachers`, which is a listview and open the model, `preacher.php`. Here are `preachers`, we can scroll down and see that in its query, it has `getItems` and here it got a `getListQuery`. [00:02:51](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m51s) It is getting all the items from the database with no input from the URL whatsoever. It does not do any of that and then it just gives it back. It does not need a URL value. [00:03:18](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m18s) So that means it most probably will only set this value `$ vars['view']='preachers';`. All of this(follow on video) will be redundant because it is a listview, there is not an alias. We are not looking at an individual item so there is not an `id`, this code can be removed. [00:03:44](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m44s) It is a default being generated.
|
If we look at `preachers`, which is a listview and open the model, `preacher.php`. Here are `preachers`, we can scroll down and see that in its query, it has `getItems` and here it got a `getListQuery`. [00:02:51](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m51s) It is getting all the items from the database with no input from the URL whatsoever. It does not do any of that and then it just gives it back. It does not need a URL value. [00:03:18](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m18s) So that means it most probably will only set this value `$ vars['view']='preachers';`. All of this(follow on video) will be redundant because it is a listview, there is not an alias. We are not looking at an individual item so there is not an `id`, this code can be removed. [00:03:44](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m44s) It is a default being generated.
|
||||||
|
|
||||||
Preachers are the listview, but then there is a view called `preacher`, and it says that it needs to get the `id` from the `sermon` table which is an error. [00:04:09](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m09s)If I open the `preacher`, and look at the `getlistQuery`, there it is getting an `id` from the URL. It is asking that it should be `= to preacher`. [00:04:34](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m34s) It is the main table, `sermondistributor` , but it is not looking for the `sermon id`, it is looking for the `preacher` value in the sermon table. That is why JCB fell back onto the table name. Yet it should go to the preacher table and see whether [00:04:59](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m59s) that preacher value is `=` to this `id`. It creates an error. You should understand the logic of what you see in the code, if not, then this feature in JCB, will not be useful for you. <<<<<<
|
Preachers are the listview, but then there is a view called `preacher`, and it says that it needs to get the `id` from the `sermon` table which is an error. [00:04:09](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m09s)If I open the `preacher`, and look at the `getlistQuery`, there it is getting an `id` from the URL. It is asking that it should be `= to preacher`. [00:04:34](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m34s) It is the main table, `sermondistributor` , but it is not looking for the `sermon id`, it is looking for the `preacher` value in the sermon table. That is why JCB fell back onto the table name. Yet it should go to the preacher table and see whether [00:04:59](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m59s) that preacher value is `=` to this `id`. It creates an error. You should understand the logic of what you see in the code, if not, then this feature in JCB, will not be useful for you.
|
||||||
|
|
||||||
### getVar Class - See What It Is Going To Do - How It Is Getting The Values
|
### getVar Class - See What It Is Going To Do - How It Is Getting The Values
|
||||||
|
|
||||||
[00:05:31](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m31s)
|
[00:05:31](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m31s)
|
||||||
|
|
||||||
I know that this is an error because we want to get the value, the id of the preacher is the one we need to check. It is doing it wrong, this value here should be preacher not sermon. You can look at the getVar class here at the bottom. Here you can see what it's going to do, and how it's going to get the values. [00:05:56](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m56s) You can also use the getVar class for your own purposes. At this point, we see at least one of the router case within the parse method. In the case loop, there's at least one router area that needs to be changed. I know by having looked at this before, that there is more than one, it's also categories. [00:06:25](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m25s) This one should also change(see video), it should be set true because this is a category lookup.
|
This is an error because we want to get the value, the `id` of the `preacher` is the one we need to check. It is doing it wrong, this value here should be `preacher` not `sermon`. You can look at the `getVar` class here at the bottom. Here you can see what is it going to do, and how it is going to get the values. [00:05:56](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m56s) You can also use the `getVar` class for your own purposes. At this point, we see at least one of the router case within the parse method. In the case loop, there's at least one router area that needs to be changed. I know by having looked at this before, that there is more than one, it is also `categories`. [00:06:25](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m25s) This one should also change(see video), it should be set `true` because this is a category lookup.
|
||||||
|
|
||||||
### Another Change To Be Made - Series
|
### Another Change To Be Made - Series
|
||||||
|
|
||||||
[00:06:38](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m38s)
|
[00:06:38](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m38s)
|
||||||
|
|
||||||
Now the other place also needs to change is 'series'. 'sermon' should also be 'series' [00:06:43](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m43s) So this is where the guessing which JCB does dynamically did not match the complexity of our Dynamic Gets. I'm sure that as time goes on we might improve it's guessing. We might get better ways of guessing correctly and within the dynamics of the Dynamic Gets, be able to build this case more effectively. Since we have not done that yet, [00:07:17](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m17s) the quickest way for us to resolve this and which most probably be the most dynamic option, is adding a way that you can replace the snippet of code, targeting the specific view. You will never need to know what is the view when you do this because they are placeholders. You need only to remember where you add your Dynamic Get.
|
Now the other place also needs to change is '`sermon`' it should also be '`series`' [00:06:43](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m43s) So this is where the guessing which JCB does dynamically did not match the complexity of our Dynamic Gets. As time goes on we might improve its guessing and get better ways of guessing correctly within the dynamics of the Dynamic Gets to build this case more effectively. [00:07:14](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m14s) Since it had not been done yet, the quickest way for us to resolve this and which most probably will be the most dynamic option, is to add a way to replace the snippet of code and target the specific view. You will never need to know what is the view when you do this because they are placeholders but only need to remember where you have added the Dynamic Get.
|
||||||
|
|
||||||
Let me go and illustrate this within the JCB interface. All I wanted to show you here is that we are targeting with this new dynamic implementation, [00:07:53](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m53s) this little snippet, this little area(see video). We are not replacing the whole method, because it is standard, there's not much to do in improving that, and if we do, it will be improving it for everyone. The build function is working well. I haven't seen any issues with that. At the end of the day, it seems like only the parse method needed a bit of an improvement.
|
To illustrate this within the JCB interface. With this new dynamic implementation, the snippet in this area is targeted(follow on video). [00:07:53](https://www.youtube.com/watch?v=hYycPLbaMos&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m53s) The whole method is not replaced, because it is standard, there is not much to do in improving that. The 'Build' function is working well. I have not seen any issues with that. At the end of the day, it seems like only the `parse` method needed a bit of an improvement.<<<<<<<
|
||||||
|
|
||||||
### The Interface Where You Can Make Changes In Dynamic Gets
|
### The Interface Where You Can Make Changes In Dynamic Gets
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user