Updated 028 How to change exported values and setup custom import options (markdown)

Amigo 2019-07-06 12:13:19 +02:00
parent 5b91ffd1bb
commit 4d58069963
1 changed files with 4 additions and 6 deletions

@ -16,18 +16,16 @@ Exporting the data in large quantities is not advisable in Joomla. If quantitie
### Exported Example In XLS Format
Click 'Export', save this(Opening Ip_tables). It has been exported, all these AUS values are displayed, and some other values from the database as expected. But if it is suppose to be a different value when it is exported, then the take the next step.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
Click 'Export', save this(Opening Ip_tables). It has been exported, all these AUS values are displayed, and some other values from the database as expected. But if it is suppose to be a different value when it is exported, then take the next step.
### Export Data In Code
### Export Data In Code
Component Builder has this 'getExportdata' method in the model.[00:03:26](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m26s)
This 'getExportdata' method has this extra value called '$_export' set to 'true'.[00:03:52](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m52s) A reason why this had been added, is to target this(See video) method with custom scripting. But the difficulty is that this part($group to $query) is custom scripting and it's also been added into the actual 'getlistquery'. [00:04:21](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m21s) It is the same custom scripting. In the compiler the same custom script is added into the 'getlistquery' as into 'getExportdata. The way to know where it gets executed, is through this value($_export). [00:04:49](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m49s) This value is not set in the 'listquery' it is only set in the export data.
This 'getExportdata' method has this extra value called '$_export' set to 'true'.[00:03:52](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m52s) A reason why this had been added, is to target this(See video) method with custom scripting. But the difficulty is that this part($group to $query) is custom scripting and it is also been added into the actual 'getlistquery'. [00:04:21](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m21s) It is the same custom scripting. In the compiler the same custom script is added into the 'getlistquery' as into 'getExportdata. The way to know where it gets executed, is through this value '$_export'. [00:04:49](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m49s) This value is not set in the 'listquery', it is only set in the Export Data.
### Admin View - PHP - (GetListQuery)
The custom scripting is done in the 'Editing the Admin View' area. With the Admin View open, go to PHP and then scroll down until the method ' Add PHP (getListQuery - JModellist)' can be seen and set it to 'Yes'. [00:05:43](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m43s) The code, that is put there, is added both to the 'getListQuery', as well as to 'exportquery'.<<<<<<
The custom scripting is done in the 'Editing the Admin View' area. With the Admin View open, go to PHP and then scroll down until the method ' Add PHP (getListQuery - JModellist)' can be seen and then it should be set to 'Yes'. [00:05:43](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m43s) The code, that is put there, is added both to the 'getListQuery', as well as to 'exportquery'.<<<<<<
If you want to change the values that are being exported, but not the values that's being shown in your component, you will be doing it in the same area. So going back here you'd see that it's that's the same code over here that is also added over here. You will see that's the same code. [00:06:22](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m22s) If you were for example in here(see video), you wanted to change some value, you could do that by simply adding another lookup or something, and you add this export is true. Now to see where all this export = true is appearing. We would go to any list model and we would search and see there it is. [00:06:55](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m55s) And there it is again. We are now in the getExportdata, we are in the area, where is looking, remember we showed you in the previous tutorial how to add some customisation to your values in the listview, some HTML, well here we are asking if the export set? or is it true? Then Don't do this. Don't add this feature here. [00:07:25](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m25s) We are avoiding adding this customisation of coloring because we don't wanted to run when we are exporting. We only wanted the values. Again you can see we're using the export values. So those are the places where the export function is coming in to play, and how we can by using this [00:07:53](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m53s) _export we are able to identify whether it's an export or not. If it is we can make the changes to the values as we like. Then going back to our back end just to show you this(PHP) is the place where we did the query. And this is the place - before the translation fix, decryption. We are checking whether we are doing an export. And so you could literally take that(see video) [00:08:30](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m30s) and say instead of the exclamation that if the export 'isset' and export is true, then over here do your thing in that area there. That is if you want to change the values before translation or before decryption or if you want to you can do it after that. So after all was done you want to change the values [00:09:18](https://www.youtube.com/watch?v=fau5mZ6naLc&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m18s) on an export. Then you can add it there. And that is really as simple as it is. Adding a change to your exported values.