Updated 044 Hello World Component with Joomla Component Builder Creator Extended (markdown)

Amigo 2019-08-21 17:31:24 +02:00
parent 335f74fe71
commit 3b3a2e0887

@ -399,27 +399,32 @@ Before Greetings can be added to the Site Menu let us first write a few greeting
[01:11:13](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h11m13s)
The reason is the Front Site View had been set to have Access control. Since it was not set therefore by default does not allow anyone. Now set it that it should by default be public. [01:11:49](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h11m49s) It is the way you should ship the Component. If you only add that feature later, you need to do Custom Scripting in the Script area which is beyond this Hello World Component to update a Database and ensure that this view is public. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
The reason is the Front Site View had been set to have Access control. Since it was not set therefore by default does not allow anyone. Now set it that it should by default be public. [01:11:49](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h11m49s) It is the way you should ship the Component. If you only add that feature later, you need to do Custom Scripting in the Script area which is beyond this Hello World Component to update a Database and ensure that this view is public.
### Manual Way To Change Access Control
[01:12:13](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h12m13s)
The manual way to do this is to go to the Hello World Component, click on Options. Then go to Permissions scroll down to the area where you see Greetings (site) Access. Select the Public group and change Greeting (site) Access to Allowed. This will now ensure that the Site area is available to the public. Having refreshed the Public area we know see James, Williams, Sarah, and Koos, all of them loading as expected.
The manual way to do this is to go to the Hello World Component, click and on 'Options'. Then go to Permissions and scroll down to the area 'Greetings (site) Access'. Select the Public group and change Greeting (site) Access to Allowed. This will now ensure that the Site area is available to the public. Having refreshed the Public area we know see James, Williams, Sarah, and Koos, all of them loaded as expected.
## Adding A Link
[01:13:00](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h13m00s)
Let's add a link to James so that when you click it you see the Greeting that James should receive. We go back to the Site Views and we open the Greetings. Now we want to add a link. But there is a better way of doing a link in JCB which takes care of all the [01:13:27](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h13m27s) controller issues. When I go to the front end of the Component then we open the models for greetings.php, we will see that there is the getItems method. And in it, we are checking whether this item has an alias. If it does have an ($item->id) and an ($item->id), it creates what is known as a $item->slug. This ($item->alias) and ($item->id) is combined [01:13:58](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h13m58s) into the $item->slug. Since we know that our greetings area does not have an alias. It only has an id. It will only end up with an id in the slug.
Add a link to James so that when you click it, will see the Greeting that James should receive. Go back to the Site Views and open the Greetings. Now we want to add a link. But there is a better way of doing a link in JCB which take care of all the controller issues. [01:13:27](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h13m27s) In the front end of the Component the models for greetings.php can be opened, there is the getItems method. In it may be checked whether this item has an alias. If it does have an ($item->id) and an ($item->id), it creates what is known as a '$item->slug'. This ($item->alias) and ($item->id) is combined into the '$item->slug'. [01:13:58](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h13m58s) Since our greetings area does not have an alias but only has an ID. It will only end up with an ID in the slug.
### Adding An Alias
[01:14:11](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h14m11s)
Let's go add an alias to our Greeting. There is a shortcut to the Fields linked to an Admin area. It's this little icon underneath Greetings. We want to add another Field called Alias. If you go to the Fields we'll see that there is already a Field called Alias. We can simply use that Field. Go back to the Admin Views and we'll click on this shortcut icon underneath Greetings for adding fields. We going to [01:14:52](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h14m52s) click the green plus button and add an Alias. We going to tell the system that this is an Alias. Now we are moving(alignment) both of these Above Tabs. We are creating the Alias to be second in line. In the Greetings, we are going to make it full width in Alignment. [01:15:18](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h15m18s)
Add an alias to the Greeting. There is a shortcut to the Fields linked to an Admin area. It is this little icon below Greetings. We want to add another Field called Alias. In Fields there is already a Field called Alias, simply use that Field. Go back to the Admin Views and click on this shortcut icon below Greetings to add fields. [01:14:52](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h14m52s) Click the green plus button and add an Alias. Now (alignment) both of these Above Tabs are moved. An Alias is created in the second line. In Greetings, make it full-width Alignment. [01:15:18](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h15m18s) The Greetings will also be edited so that it is no longer a text field but a text area. With all in its place, Save and Close. Open the Greetings in Fields. Since there are some values that I want to stay the same, I am going to select the XML Definition and copy it.[01:15:51](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h15m51s) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
We also going to go edit the Greetings in a moment so that it's no longer a text field but a text area. We got all in its place, save and close. Going back to Fields, I'm going to open the Greetings. Since there are some values I want to stay the same. I am going to select [01:15:51](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h15m51s) the XML Definition and I'm going to copy it. Then I'm going to select Textarea. I'm going to paste that first XML in here. We have to remove it again but just so I can copy, paste. [01:16:13](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h16m13s) Cut the name. I want to keep the same name. You can't change the type because the Type up at the top of the page needs to correspond with the type in the XML. Changing the type in the XML will not work. The label you want to keep that the same. We want to add greetings as a description. We don't want to default text. [01:16:57](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h16m57s) Let's add the hint back again. We don't need any of these other fields, so we can just remove them. We don't want the filter to be set to raw. We would rather use the word string. Since we don't want any HTML at this stage in our greetings. If you want HTML now in the greeting you can use the Save HTML. I see it's not in this list but it does exist. Usually, we would use the editor instead of just a textarea. [01:17:43](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h17m43s) We got our textarea replace and I'm going to add 'class.'text_area span 12'. I don't know how long that's going to still be there as a class. I think it is still there. I think that should do it. Save and close. [01:18:11](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h18m11s) Since we didn't change any of the Database values with this text field, we shouldn't have any issues. But we did add a new text field. If we go to the Compiler and we compile the Component, you will see that it dynamically incremented the version 2_0_1. If we go without installing we go to the Component you will see that it hasn't updated the view because this was open. Before doing anything I would suggest reopening the view, refresh the page. So that the changes will show.
Then I'm going to select Textarea. I'm going to paste that first XML in here. We have to remove it again but just so I can copy, paste. [01:16:13](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h16m13s) Cut the name. I want to keep the same name. You can't change the type because the Type up at the top of the page needs to correspond with the type in the XML. Changing the type in the XML will not work. The label you want to keep that the same. We want to add greetings as a description. We don't want to default text. [01:16:57](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h16m57s) Let's add the hint back again. We don't need any of these other fields, so we can just remove them. We don't want the filter to be set to raw. We would rather use the word string. Since we don't want any HTML at this stage in our greetings. If you want HTML now in the greeting you can use the Save HTML. I see it's not in this list but it does exist. Usually, we would use the editor instead of just a textarea. [01:17:43](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h17m43s) We got our textarea replace and I'm going to add 'class.'text_area span 12'. I don't know how long that's going to still be there as a class. I think it is still there. I think that should do it. Save and close. [01:18:11](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h18m11s) Since we didn't change any of the Database values with this text field, we shouldn't have any issues. But we did add a new text field. If we go to the Compiler and we compile the Component, you will see that it dynamically incremented the version 2_0_1. If we go without installing we go to the Component you will see that it hasn't updated the view because this was open. Before doing anything I would suggest reopening the view, refresh the page. So that the changes will show.
### Install The New Changes