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

And so these selections before, is only really necessary when you select main menu and submenu. Because then you want to say before what item you want this menu to be created. We selected dashboard list of records. 00:03:55 And because of that it places that in combined results. And you need to select the records that you want to look at and then you can click on the combined results. They'll grab those ids and since we are modelling, data in the controller and the model, it gives back to the view these results through the custom implementation we've done. Just a quick refresher. 00:04:25

How Buttons are Implemented - Important

If we go to component builder, and custom admin views, we open company results. We see that in the custom buttons, we added the php. We also added the button. We explain to component builder what kind of buttons we want. We set we are targeting a single item, you see editCompany gotoCompany, those buttons 00:04:55 are actually related to going inside of the view. Then if you come out of this(Editing the Custom Admin Views), we see that even in combined results, we also added buttons. But again those buttons Vcard, companies, gotocompanies, corresponds to the controller. If we go to the view itself, 00:05:27 we'll see that, that's not responding to this(see video) button but actually to the buttons inside called companies and edit. Those are the buttons you were building in the custom view. Where as the buttons we are looking at in here(see video), is related to opening the custom view itself. That is just a quick refresher.

Same goes with the combined results. The combined results is the button that you are setting up here(custom admin view). 00:06:02 Where as for the other buttons are, once you have combined them, and you've click combined results, you will see that it adds two buttons, dashboard and companies. Those two buttons was set up in the view itself. You can know and understand what area controls what set of buttons. This area controls the buttons before opening the view. Where as in the view, the buttons your setting up there, is for when you have opened the view. That is setting up a custom admin view 00:06:38 to your component.

Some of the switches obviously again, if anything is unclear or you not exactly sure, you can come and undo anything. So simply go change it to what you would think should work and compile a component, and go look in the code, and see what has been done and look in the Joomla if the face, and see what is being displayed. Play around with it 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