Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

016. Adding Ordering and Filter

Astrid edited this page Jan 29, 2020 · 8 revisions

Adding Ordering and Filter

In this chapter we will ...

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.

Foo Manager Administration Search Tools

Newly created or Modified files

Newly created files

administrator/components/com_foos/forms/filter_foos.xml

administrator/components/com_foos/sql/updates/mysql/1.16.0.sql

Modified files

changelog.xml

foo_update.xml

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

All changes at a glance

Click here to see all changes compared to the last chapter.

More detailed explanations

File Structure

Newly created files

We will start off by adding a template that contains all necessary fields.

If you are interested in the parameter inputmode: See developer.mozilla.org.

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

filterfooxml2 filterfooxml1

administrator/components/com_foos/sql/updates/mysql/1.16.0.sql

database database2

Modified files

And as usual: We need to modify our installation XML file, the update server and the change log to include the new version.

changelog.xml

changelog

foo_update.xml

updatexml

administrator/components/com_foos/forms/foo.xml

fooxml

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

model1

model2

model3

model4

model5

administrator/components/com_foos/View/Foos/HtmlView.php

view3 view2 view1

administrator/components/com_foos/foos.xml

foosxml

administrator/components/com_foos/language/en-GB/en-GB.com_foos.ini

langeng

administrator/components/com_foos/tmpl/foos/default.php

default

default2

default3

administrator/components/com_foos/tmpl/foos/modal.php

modal

Example in Joomla 4

Side Note

Test your component

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.

Concluding Remark

Now we have . Up to now we have no . We are going to work on this in the next chapter.

Overview of all files

Clone this wiki locally