help to better help you:

Please: add always Joomla / JEM version and details to your posts, so we can try to reproduce your issue!

J3 - searchtools in front (like searchtools backend)

J3 - searchtools in front (like searchtools backend)

9 years 9 months ago
#17851
after gettting a bunch of "document expired" errors by using the search-module i was wondering if it was due to the module and if it would make a difference if the searchtools (backend) would be added to the front.

so did include it to the front (see images)



so do know how to include it in the front but am having the same results :(
"document expired" happens when selecting some options, visiting a link to the event and then pressing the back button.

but here some info of how to include it in the front:


populatestate
you can add code from libraries/legacy/model/list.php to it.
code like:
Code:
if ($filters = $app->getUserStateFromRequest($this->context . '.filter', 'filter', array(), 'array')) { foreach ($filters as $name => $value) { $this->setState('filter.' . $name, $value); } } $limit = 0; // Receive & set list options if ($list = $app->getUserStateFromRequest($this->context . '.list', 'list', array(), 'array')) { foreach ($list as $name => $value) { // Extra validations switch ($name) { case 'fullordering': $orderingParts = explode(' ', $value); if (count($orderingParts) >= 2) { // Latest part will be considered the direction $fullDirection = end($orderingParts); if (in_array(strtoupper($fullDirection), array('ASC', 'DESC', ''))) { $this->setState('list.direction', $fullDirection); } unset($orderingParts[count($orderingParts) - 1]); // The rest will be the ordering $fullOrdering = implode(' ', $orderingParts); if (in_array($fullOrdering, $this->filter_fields)) { $this->setState('list.ordering', $fullOrdering); } } else { $this->setState('list.ordering', $ordering); $this->setState('list.direction', $direction); } break; case 'ordering': if (!in_array($value, $this->filter_fields)) { $value = $ordering; } break; case 'direction': if (!in_array(strtoupper($value), array('ASC', 'DESC', ''))) { $value = $direction; } break; case 'limit': $limit = $value; break; // Just to keep the default case default: $value = $value; break; } $this->setState('list.' . $name, $value); } }
the thing is that we do like to add an Itemid so it's good to override the code and make some adjustments


view.html.php
as we are going to use a JLayout we do add some code to the view.html.php
Code:
$this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters');
by adding them you also have to add a filter xml to the /models/forms directory

Filter Xml
so for example we can create a filter_eventslist.xml with content like
Code:
<?xml version="1.0" encoding="utf-8"?> <form> <fields name="filter"> <field name="search" type="text" label="COM_JEM_GLOBAL_FIELD_FILTER_SEARCH_DESC" hint="JSEARCH_FILTER" class="input-medium" /> <field name="published" type="status" label="COM_JEM_GLOBAL_FIELD_FILTER_PUBLISHED" description="COM_JEM_GLOBAL_FIELD_FILTER_PUBLISHED_DESC" class="input-medium" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_PUBLISHED</option> </field> <field name="filter_type" type="list" label="COM_JEM_GLOBAL_FIELD_FILTER_FILTERTYPE" description="COM_JEM_GLOBAL_FIELD_FILTER_FILTERTYPE_DESC" class="input-medium" > <option value="">- Select Filtertype -</option> <option value="1">COM_JEM_EVENT_TITLE</option> <option value="2">COM_JEM_VENUE</option> <option value="3">COM_JEM_CITY</option> <option value="4">COM_JEM_CATEGORY</option> <option value="5">COM_JEM_STATE</option> <option value="6">COM_JEM_COUNTRY</option> <option value="7">JALL</option> </field> </fields> <fields name="list"> <field name="limit" type="limitbox" class="inputbox input-mini" default="10" label="COM_JEM_GLOBAL_FIELD_LIST_LIMIT" description="COM_GLOBAL_FIELD_LIST_LIMIT_DESC" onchange="this.form.submit();" /> </fields> </form>

default_events_table.php
in the table file we make a call to the layout file.
Code:
<?php // Search tools bar echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this),JPATH_COMPONENT); ?>
Did use JPATH_COMPONENT as it's good to have the layout within the JEM folder so you can override things and make adjustments.

so did copy: "layouts/joomla/searchtools" and copied it to "components/com_jem/joomla/searchtools"

maybe there are some more things that should be adapted but that's something for you to find out :)

Attachments:

Please Log in or Create an account to join the conversation.

Re: J3 - searchtools in front (like searchtools backend)

9 years 9 months ago - 9 years 9 months ago
#17852
[strike]about the "document expired":

did install the plugin "expires Headers" and it seems to do the trick, didn't see the notices for a while so let's hope they won't show up anymore.[/strike]

forget the above, still having issues :(

//
did also try it out in the back (articles / JEM) and there it's also giving problems.
hmm, guess it is as it is and won't spend much more time to it.
Last edit: 9 years 9 months ago by Bluefox.

Please Log in or Create an account to join the conversation.

Re: J3 - searchtools in front (like searchtools backend)

9 years 9 months ago
#17853
about the searchtools front.

in the backend the filterbar is closed when no options have been choosen (status, title, etc...) but it in the front that doesn't seem to happen.

had to add some jquery code to have the same effect as the backend but will take a closer look later.

another thing is that the searchtool layout didn't had an id applied to it, making things harder to change. so did add it.

Please Log in or Create an account to join the conversation.

Time to create page: 0.513 seconds