Updated 038 Setup Site Edit View in JCB (markdown)
parent
09d506df72
commit
5d49a42d0b
@ -26,14 +26,16 @@ In JCB there is a switch that can be flipped for JCB to write the code for the s
|
|||||||
|
|
||||||
### Code - Controller - Model - View
|
### Code - Controller - Model - View
|
||||||
|
|
||||||
[00:06:05](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m05s)<<<<<<<
|
[00:06:05](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m05s)
|
||||||
|
|
||||||
Now let's go look at the code. Looking at the demo websites folder structure, we are going to components. We'll see that there is a com_demo folder. [00:06:19](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m19s) We will see there is the models as well as the controllers as well as the views. This is the view that was dynamically generated by JCB. The view, the model and the controller are called look. You can open (controller look.php) to see what was the code that was written. [00:06:49](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m49s) You can see it looks very similar to the admin area except that it's been slightly modified for your front end and it's requirements. As you can see we were adding some CSS classes and JavaScript from the back end. Here is the model, [00:07:16](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m16s) getItem, getForm, and the controller. We are showing you the code what was created. The fact that this was created, doesn't mean that there is a set of links that you can click and edit the forms which was submitted or that there is a link to create any. These things is what you need to do manually. [00:07:51](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m51s)
|
Looking at the demo websites folder structure in the code, there is a com_demo folder under components. [00:06:19](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m19s) There are the Models as well as the Controllers and the Views. This is the View that was dynamically generated by JCB. The View, the Model and the Controller are called 'Look'. Open (controller look.php) to see what was the code that was written. [00:06:49](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m49s) It looks very similar to the Admin Area except that it has been slightly modified for the front end and its requirements. As you can see we were adding some CSS classes and JavaScript from the back end. Here is the 'model','getItem', 'getForm', and the Controller.[00:07:16](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m16s) It shows the code that has been created. The fact that this was created, does not mean that there is a set of links that you can click and edit the forms which was submitted or that there is a link to create any. These things should be done manually. [00:07:51](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m51s)
|
||||||
authores
|
|
||||||
|
|
||||||
### Manually Add Links
|
### Manually Add Links
|
||||||
|
|
||||||
Let's show you some of that. There is two views called under site views, one is called looks and other one is called looking. As you can remember the one we looked at here, which I set was automatically generate is called look, so that one isn't showing because it was a tick box that created this whole view model and controller. You don't need to build the look view again. [00:08:21](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m21s) You need to get links to it. In looks we are using a Dynamic Gets, and in looking. Let's go to the Dynamic Gets page. There is one called looks and looking. Let's go to the looks Dynamic Gets. It got a custom script area were we're asking whether the items are set whether there are items. Then we looping through them, and during the looping process we determine by $canDo script, [00:09:10](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m10s) you will see in the helper class there's a getAction function.
|
Under site views there are two views, one is called 'Looks' and other one is called 'Looking'. As you can remember the one we looked at here, which I set was automatically generated is called 'Look', so that one is not showing because it was a tick box that created this whole View model and Controller. It is not necessary to build the 'Look' view again but you need to get links to it.[00:08:21](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m21s) In 'Looks' a Dynamic Gets is used, as well as in 'Looking'. Open the Dynamic Get page. There is one called 'Looks' and 'Looking'. Go to the Looks Dynamic Get. It got a custom script area were it is asked whether the items are set or whether there are items.<<<<<<
|
||||||
|
|
||||||
|
|
||||||
|
Then we looping through them, and during the looping process we determine by $canDo script, [00:09:10](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m10s) you will see in the helper class there's a getAction function.
|
||||||
|
|
||||||
The getAction function asks whether look item, where the current user has the edit option to the specific look item. If it does it in this little script, it builds an edit look button. And dynamically adds that to the edit link, which is coupled to the item, and then continues on. It dynamically generates the button for edit in the dynamic get. [00:09:48](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m48s) You could have done that anywhere. I decided to do it here, because then it gets added to the model, which is more where your logic, for lots of your data structure should be placed. If you go back to the site views, open the looks site view. You will see that we got the main get set as looks. If you scroll down, [00:10:25](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m25s) in this area we are looping through the look items, and echoing the edit link after the description. That means the link that we built in the Dynamic Get which is the button, will either be empty and therefore show nothing. If the user doesn't have the permission to edit it, or it will show a button. [00:11:04](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m04s) As I look at this I haven't added a link for creating new looks. The same would be required to do that.
|
The getAction function asks whether look item, where the current user has the edit option to the specific look item. If it does it in this little script, it builds an edit look button. And dynamically adds that to the edit link, which is coupled to the item, and then continues on. It dynamically generates the button for edit in the dynamic get. [00:09:48](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m48s) You could have done that anywhere. I decided to do it here, because then it gets added to the model, which is more where your logic, for lots of your data structure should be placed. If you go back to the site views, open the looks site view. You will see that we got the main get set as looks. If you scroll down, [00:10:25](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m25s) in this area we are looping through the look items, and echoing the edit link after the description. That means the link that we built in the Dynamic Get which is the button, will either be empty and therefore show nothing. If the user doesn't have the permission to edit it, or it will show a button. [00:11:04](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m04s) As I look at this I haven't added a link for creating new looks. The same would be required to do that.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user