I am building a component managing a set of job offers. Jobs have attributes including "employer". (I am extending a component created with Component Creator.)
There is a front-end list view with filtering that allows users to restrict the listed jobs to a particular employer (among other filtering options). Selecting an employer filter causes the following GET request to be generated:
http://localhost/joomla/index.php/job-boerse/set-of-jobs?filter[employer]=Google&<some more stuff>
This works nicely. However, now I wish to create a menu item type with an option, the employer, so I can create menu items, such as, Google Jobs, Apple Jobs, etc.. Essentially, I wish the menu items to preset the filter with a particular value that can be specified during menu item definition.
Ok. So I added the following options to the menu item type definition (joomla/components/com_jobs/views/jobs/templ/default.xml):
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_JOBS_TITLE_LIST_VIEW_JOBSFULL" option="View">
<message>
<![CDATA[COM_JOBS_TITLE_LIST_VIEW_JOBSFULL_DESC]]>
</message>
</layout>
<!-- Add fields to the request variables for the layout. -->
<fields name="request">
<fieldset name="request">
<field name="employer"
type="text"
hint="COM_JOBS_FILTER_EMPLOYER_HINT"
label="COM_JOBS_JOBS_EMPLOYER"
class="js-stools-search-string" />
</fieldset>
</fields>
</metadata>
This works except, the Menu Item Link the system constructs is this:
index.php?option=com_jobs&view=jobs&employer=Google
instead of
index.php?option=com_jobs&view=jobs&filter[employer]=Google
Ok. So I changed the employer field name in default.xml as follows:
<field name="filter[employer]" ...
However, now, the system is unable to construct the Link for the menu item. I was hoping it would make the following Link but it didn't:
index.php?option=com_jobs&view=jobs&filter[employer]=Google
Moreover, when I save the menu item, the value of the employer field disappears from the form.
I guess, what I am missing is an understanding of how Joomla builds the Links for menu items with options. Maybe I need to change the option name from "employer" to "filter[employer]" in some other place as well?