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

Amigo 2019-08-22 10:16:30 +02:00
parent bd1eff83a1
commit a44a60b9ac
1 changed files with 11 additions and 19 deletions

@ -327,7 +327,7 @@ There are Layouts and Templates that all can work together with Site Views. (Loo
[00:58:30](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h58m30s)
I am going to build two Site Views. The first Site View is called the 'System Name Greetings'. Give it a Name called 'Greetings' and a Code Name 'greetings'.
I am going to build two Site Views. The first Site View is called; (System Name) 'Greetings'. Give it a Name called 'Greetings' and a Code Name 'greetings'.
* ### Name In Code
@ -394,7 +394,7 @@ When you add a front end Site View and set that default to being public and if i
[01:09:53](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h09m53s)
Before Greetings can be added to the Site Menu let us first write a few greetings. With at least four Greetings in place, continue then and add that ListView to a Front end Site View. Then go to Menus and to Main Menu. Select the Menu Type. Click on the previous Component; 'Hello World Greetings'. Greeting is set as the HOME of this website. Save and close. [01:10:54](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h10m54s) There are HOME and Hello World Greetings. That should mean that if we click on this preview(demonstration button) of the front end of the Site, the Greetings should be seen. It will show that 'The page isn't redirecting properly'.
Before Greetings can be added to the Site Menu let us first write a few greetings. With at least four Greetings in place, continue then and add that ListView to a Front end Site View. Then go to Menus and to Main Menu. Select the Menu Type. Click on the previous Component; 'Hello World Greetings'. 'Greeting' is set as the HOME of this website. Save and close. [01:10:54](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h10m54s) There are HOME and Hello World Greetings. That should mean that if we click on this preview(demonstration button) of the front end of the Site, the Greetings should be seen. It will show that 'The page isn't redirecting properly'.
### Set Front Site View To Have Access Control
[01:11:13](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h11m13s)
@ -411,45 +411,37 @@ The manual way to do this is to go to the Hello World Component, click and on 'O
[01:13:00](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h13m00s)
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.
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 takes 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)
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)
Then select 'Textarea' and paste that first XML in here, only in order to remove it again since it is just to copy and 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 not change the Type because the Type at the top of the page needs to correspond with the Type in the XML. Changing the type in the XML will not work. Keep the Label the same. We want to add 'greetings' as a description. We do not want to default text. [01:16:57](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h16m57s) Add the hint back again. We do not need any of these other fields, just remove them and do not want the filter to be set to 'raw'. We would rather use the word string since we do not want any HTML at this stage in our greetings. If you want HTML now in the greeting you can use the Save HTML. It is 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) The 'textarea' is in place and I am going to add 'class.'text_area span 12'. It is not certain how long that will be there as a class. Save and close. [01:18:11](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h18m11s) Since not any of the Database values with this text field had changed, there should not be any issues. But a new text field had been added. If the Component gets compiled in the Compiler, it may be seen that it dynamically incremented the version 2_0_1. If we go to the Component without installing, you will see that it has not updated the view because this was open. Before doing anything I would suggest that the view should be reopened and the page refreshed so that the changes can show.<<<<<<<
Then select 'Textarea' and paste that first XML in here, only in order to remove it again since it is just to copy and 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 not change the Type because the Type at the top of the page needs to correspond with the Type in the XML. Changing the type in the XML will not work. Keep the Label the same. We want to add 'greetings' as a description. We do not want to default text. [01:16:57](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h16m57s) Add the hint back again. We do not need any of these other fields, just remove them and do not want the filter to be set to 'raw'. We would rather use the word string since we do not want any HTML at this stage in our greetings. If you want HTML now in the greeting you can use the Save HTML. It is 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) The 'textarea' is in place and I am going to add 'class.'text_area span 12'. It is not certain how long that will be there as a class. Save and close. [01:18:11](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h18m11s) Since not any of the Database values with this text field had changed, there should not be any issues. But a new text field had been added. If the Component gets compiled in the Compiler, it may be seen that it dynamically incremented the version 2_0_1. If we go to the Component without installing, you will see that it has not updated the view because this was open. Before doing anything I would suggest that the view should be reopened and the page refreshed so that the changes can show.
### Install The New Changes
[01:19:01](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h19m01s)
Go back and install the new changes. Open a Hello World, the Alias should be seen there and if it is saved, it should dynamically add a new Alias. This has to be done for every item because the Aliases are saved or created only once the item is saved. Open the Aliases. Only ship this Component when everything in place otherwise the user has to do all this gymnastics to make sure that all the values are in place. If by some reason they have to, you will have to help them along with some Custom Scripting. [01:19:58](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h19m58s) Now with all our items set and it has an Alias, we can start working on those links.
### Changes To Be Made In Dynamic Get - Including Alias
[01:20:07](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h20m07s)
There is one more place where a change needs to be done. That is in the Dynamic Get. If you remember when we set it up we did not include the Alias. Copy this(follow steps on video). Then change to another view and then return to this one to get the alias there. We got the alias. Save and close. <<<<<<<<<
### Install The New Changes
[01:19:01](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h19m01s)
Go back and install the new changes. Open Hello World, the Alias should be seen there and if it is saved, it should dynamically add a new Alias.,<<<<<<<<< We'll have to do this for every item because the Aliases are saved or created only once you saved the item. I'm just opening all of them quickly. Usually, a user using your Component, you only going to ship this Component when you've got everything in place. They wouldn't have to do all this gymnastics to make sure that all the values are in place. If by some reason you will have to help them along with some Custom Scripting. [01:19:58](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h19m58s) Now that we got all our items set and it has an Alias, we can start working on those links.
### Changes To Be Made In Dynamic Get - Including Alias
[01:20:07](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h20m07s)
There's one more place we need to make a change. That is in the Dynamic Get. If you remember when we set it up we didn't include the Alias. I'm going to copy this(see video). I then change to another view quickly and then back to this one so that we can get the alias there. Here is the alias that we want. We don't need all these. We can just add that over there. There we go. We got the alias. Select save and close.
### Check Whether Alias Brought To page By Adding a php.var_dump
[01:20:46](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h20m46s)
We can check whether this alias is being brought to the page by adding a php.var_dump. [01:21:11](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h21m11s) We take all the $this>items, copy, paste it in there php.var_dump($this>items) and save. Now we go back to the Compiler. I'm just quickly compiling this again and install. Go to the homepage [01:21:44](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h21m44s) refresh and now you will see that it dumps all the values on the page and then displace them. We can look and see there's the Alias and it created that slug we spoke about. We got the slug for every item and that is the first step in setting up a well-form link for opening one of these items. [01:22:13](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h22m13s) I don't know what some of you might think, that's got a lot of things to do to get this to work. I can tell you if you want to build Components for Joomla and you want to go outside of the box and build things that are unique and completely different from what other people are doing and this is just the basics.
It can be checked whether this alias is being brought to the page by adding a 'php.var_dump'. [01:21:11](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h21m11s) We take all the '$this>items', copy, paste it in there 'php.var_dump($this>items)' and save. Now return to the Compiler. Compile this again and install. Go to the homepage. [01:21:44](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h21m44s) Refresh and now you will see that it dumps all the values on the page and then displace them. We can look and see there's the Alias and it created that slug we spoke about. We got the slug for every item and that is the first step in setting up a well-form link for opening one of these items. [01:22:13](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h22m13s) I don't know what some of you might think, that's got a lot of things to do to get this to work. I can tell you if you want to build Components for Joomla and you want to go outside of the box and build things that are unique and completely different from what other people are doing and this is just the basics.
### Use PHP For Creating A Link