Skip to content

020 Adding Custom Admin Views to a Component

Amigo edited this page Jun 21, 2019 · 22 revisions

ADDING CUSTOM ADMIN VIEWS TO A COMPONENT

Cost-benefit projection will be used as our component.

Settings - Custom Admin View

Go to 'settings' and then to 'Custom Admin Views' . It will be seen that two 'Custom Admin Views' has been added. 00:00:20

Multiple Switches Due To Being Dynamic

It has more switches than the Site view because its implementation is more dynamic. You can choose an icon, because in the back end you possibly want to have an icon when you are on the right of the page.00:00:45 Then it can be selected where this should show in the main menu.

Icon - Main Menu - Dashboard - Submenu

The main menu drops down from Joomla's 'menu item list'. This is the specific dashboard you need to go to each time when you start with a component where all the icons are displayed. Then the 'Sub-menu' is the one on the left, which can be seen when you are in a view.00:01:14 These are all placements where this Custom View possibly may be added.

Targeting Item(some switches are no)

Remember, the company results has not been added to any of the views individually it was added to items. That's why all of these are set to 'No'. 00:01:41 That means an item is targeted in a view.

Select Target View

All that need to be done is to select the view which is targeted, which is 'Company'. Use one of these options: 'Has Metadata', 'yes' or 'no', and 'Add Access', 'yes' or 'no'. 00:02:02 Simply by selecting 'Company' it ensures that the correct view is targeted. If this is closed for a moment

Showing Within The Component

To give a example of what happened with the settings: Open the 'Cost-Benefit Projection Dashboard'. If 'Companies' is opened, you will see that it has a button for 'Company results'. 00:02:27 Now if you remember that when Custom Admin View had been set up, we ensured that an 'item id' had been targeted. By selecting 'Company', the companies 'item id' is targeted, and that is what makes it work. Click 'Chart' to view these this little charts that shows up in the icon itself. 00:02:55. If you click on it the Custom View shows up and that icon shows up next to it, and shows that all works well. A 'Combined Results' button shows up in the toolbar, the reason for that is that 'Combined Results' which were selected, should have 'Cogs' as a icon. 00:03:25 Then list of records, 'Metadata', 'Access', and 'Company' is set to 'yes'.

Order Before Selection

This 'Order Before', selections is only really necessary when a 'main menu' and 'sub-menu' are selected. Because then it may be decided before what item this menu should be creating.00:03:55 'Dashboard(list of records)' has been selected and consequently it places that in combined results. The records need to be selected that you want to look at and then click on the 'Combined results'. It will grab those ids and since the data is modeled in the controller and the model, it gives back to the view these results through the custom implementation that has been done. 00:04:25

How Buttons are Implemented - Important

  • Quick refresher

If you go to Component Builder, and Custom Admin views, and open 'Company Results'. You will see that in the Custom Buttons, PHP has been added. 'Button' was also added . A request has been made to Component Builder as to what kind of buttons is needed. A single item is targeted It shows 'editCompany' and 'gotoCompany', these buttons 00:04:55 are related to the inside of the view. On exiting 'Editing the Custom Admin Views', it even shows in 'Combined results', that 'buttons' also has been added. But again those buttons 'Vcard', 'companies', 'gotocompanies', corresponds to the controller. Going to the view itself, 00:05:27 it shows that, it not responding to this(see video) button but actually to the buttons inside called 'Companies' and 'Edit'. These are the buttons you were building in the custom view. Whereas the buttons we are looking at in here(see video), is related to opening the Custom View itself. That is just a quick refresher.

The Combined Result Button

The same applies to the Combined Results. The Combined Results is the button that is set up here(See video) 'Custom Admin View'. 00:06:02 Whereas once the other buttons is combined, and Combined Results is clicked, it shows that two buttons has been added, 'Dashboard' and 'Companies'. Those two buttons had been set up in the view itself. It is possible to know what area controls what set of buttons. This area controls the buttons before opening the view. Whereas in the view, the buttons you have set up there, is for when you have opened the view. That is setting up a Custom Admin View to your component. 00:06:38

If you are uncertain you can undo everything and simply change it and compile a component, and go look in the code, and see what has been done and look in the Joomla interface, and see what is being displayed. Do some experimenting until you get that what you expected .<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

00:07:10 Just a quick heads up this 'order before' is only compulsory when actually selecting add to main menu or add sub menu. If you use those it means that if you go to your component, you have the icons area, and here in the top you have your 00:07:34 main menu items. Once you've opened, then here on the right, you have submenu. This is main menu, this is dashboard list. Now dashboard list is that one which goes to the top of the components toolbar and then submenu is the one here on the side. 00:07:58

This custom admin view simply needs to be placed in the submenu and its lives on its own it's not related to any other dataset. Then you can use the submenu method. If you only want to featured in the main menu, these are all the features that you could set. Where as the dashboard list record feature helps you to link it to a specific set 00:08:25 of data structures like this one does. You can select these ids, and when you click on this combined results, the ids of the selected items gets passed to the controller. If I go back quickly to show you that how we use it. Combined results, custom buttons. 00:08:54 We're using the 'main get' called companies data (getlistquery). Let's go and look at that data query, I think that's where we will find the use or the implementation of those ids. We are basically reaching into the input object here. We getting cid, 00:09:35 selected ids, and we saying tt can be CMD. Then we are exploding it, and we are making sure it is intervals, and we placing it in ids. This actually gets 'this' value from the post object, 00:09:59 and places that into ids. Here we do some validation to ensure that the person who's trying to access the data has actualy the right to do it. Once we pass that, we basically use those ids to get the data.

In the filter 00:10:20 we use ids, and check whether all the ids are in a id and that in the code. Basically if you look at the code, it's on the models combine results. We see that it uses our checking method here. Later down here it checks the ids. 00:10:45 Puts it in an array. check if it's in an array then implodes it. Checks whether it gets those ids. That's how we filtered the dataset with the results of the selection. That's just a little bit looking into the back end on how to make use of those 00:11:07 features and you can see, it's some custom scripting we added to the dynamic get method. To take those ids and to use them in the way we intend. You can ignore them, but here is the way that I implemented it.

If you want to drop that down, pause the video, and copy some of this area here. I think it would be the only part that will be useful to your purpose. Then you can use the ids in your code 00:11:39 as you please. Know that this php as you saw in the code, it runs before the get methods. It basically is a filtering option as you see there(see video). This query starts, then that code be wrote, is entered in here and then the rest of the code which is build by component builder is being done. You can use a filter option with whatever you 00:12:07 collected up here. That's Looking into adding custom admin views to component builder. Just showing you again the tremendous leverage and design choices you can make in ensuring that your component is dynamic, and get sort of breaks out of the mold so that you can achieve 00:12:32 nice complex components write inside component builder.

Clone this wiki locally