-
Notifications
You must be signed in to change notification settings - Fork 30
016. Adding Ordering and Filter
Now, we want to create filters and search tools.
In Joomla 4, there are like in Joomla 3 some view filters and search tools that allow you to limit the items shown. For instance, only showing items where the status is published.
Besides the
- status filter, we usually expect to see
- search in title or content,
- sort table by, and
- ordering.
Newly created files
administrator/components/com_foos/forms/filter_foos.xml
administrator/components/com_foos/sql/updates/mysql/1.16.0.sql
Modified files
administrator/components/com_foos/Model/FooModel.php
administrator/components/com_foos/Model/FoosModel.php
administrator/components/com_foos/View/Foos/HtmlView.php
administrator/components/com_foos/foos.xml
administrator/components/com_foos/forms/foo.xml
administrator/components/com_foos/language/en-GB/en-GB.com_foos.ini
administrator/components/com_foos/tmpl/foos/default.php
administrator/components/com_foos/tmpl/foos/modal.php
Click here to see all changes compared to the last chapter.
We will start off by adding a template that contains all necessary fields.
administrator/components/com_foos/forms/filter_foos.xml
We can now save a custom order. For this we need an entry in the database. The file administrator/components/com_foos/sql/updates/mysql/1.16.0.sql
ensures that the column is created during the update. We don't need to do much more. Everything else is done by Joomla! for us
administrator/components/com_foos/sql/updates/mysql/1.16.0.sql
And as usual: We need to modify our installation XML file, the update server and the change log to include the new version.
administrator/components/com_foos/forms/foo.xml
We have adjusted the database. We adapt the model so that the order is saved here. Otherwise it doesn't actually work. Moreover we need to modify the model so that it filters the results shown based on the value of the filter.
administrator/components/com_foos/Model/FooModel.php
administrator/components/com_foos/Model/FoosModel.php
administrator/components/com_foos/View/Foos/HtmlView.php
administrator/components/com_foos/foos.xml
administrator/components/com_foos/language/en-GB/en-GB.com_foos.ini
administrator/components/com_foos/tmpl/foos/default.php
administrator/components/com_foos/tmpl/foos/modal.php
Now you can zip all files and install them via Joomla Extension Manager. After that you can see a link to your component in the left side menu. Clicking on this link will open the basic backend view.
Now we have . Up to now we have no . We are going to work on this in the next chapter.