? Success

User tests: Successful: Unsuccessful:

avatar phproberto
phproberto
21 Sep 2013

Search tools for Joomla!

This adds to Joomla! a filter system like the used in google images to filter them. The idea was born in the JUX Code Sprint in Manchester

The main goal was to avoid the use of the left sidebar in item list managements to allow a full size item list. That will make available more space for columns and use the left side of the screen for the hot content instead of the filters. This PR only removes the sidebar filters but keeps the sidebar menu that is removed in a different JUX pull request. This is to ensure that all JUX contributions are fully independent.

Closed:
stools_closed

Open:
stools_open

Main features

  • The system adds to Joomla! the option to use standard JForm forms for item list filtering. That saves us to deal with states & to hardcode selects in HTML.
  • It uses JLayout so all the system can be easily moved, customised and/or reused.
  • It uses standard JForm fields so adding and remove filters is as easy as copy 6-10 lines of code in an XML file.
  • Filters and list modifiers are received and added automatically so the system is 100% reusable for extension development. In fact 3rd part developers that want to use the system mainly have to remove code.

Joomla! improvements / fixes

  • Adds the option to filter by tag to featured articles.
  • Adds the option to filter by purchase_type to banner clients. Also adds the missing ordering for some column headings: clients

New field types available

JFormFieldPredefinedList

New abstract class to create a select field with a predefined list of values. Fields that extend it basically have to add a list of values like:

    /**
     * Available options
     *
     * @var  array
     * @since  3.2
     */
    protected $predefinedOptions = array(
        'today'       => 'COM_USERS_OPTION_RANGE_TODAY',
        'past_week'   => 'COM_USERS_OPTION_RANGE_PAST_WEEK',
        'past_1month' => 'COM_USERS_OPTION_RANGE_PAST_1MONTH',
        'past_3month' => 'COM_USERS_OPTION_RANGE_PAST_3MONTH',
        'past_6month' => 'COM_USERS_OPTION_RANGE_PAST_6MONTH',
        'past_year'   => 'COM_USERS_OPTION_RANGE_PAST_YEAR',
        'post_year'   => 'COM_USERS_OPTION_RANGE_POST_YEAR',
    );

The field also supports to filter a specific list of the available values adding to the field definition the attribute filter. Sample field definition only selecting some of the previous values:

        <field
            name="range"
            type="registrationdaterange"
            filter="today,past_1month,past_6month"
            label="COM_USERS_OPTION_FILTER_DATE"
            description="COM_USERS_OPTION_FILTER_DATE"
            onchange="this.form.submit();"
            >
            <option value="">COM_USERS_OPTION_FILTER_DATE</option>
        </field>

JFormFieldStatus

Shows a list of content status. Values possible are:

    /**
     * Available statuses
     *
     * @var  array
     * @since  3.2
     */
    protected $predefinedOptions = array(
        '-2' => 'JTRASHED',
        '0'  => 'JUNPUBLISHED',
        '1'  => 'JPUBLISHED',
        '2'  => 'JARCHIVED',
        '*'  => 'JALL'
    );

JFormFieldUserActive

Shows a list of user account statuses. Values possible:

    /**
     * Available statuses
     *
     * @var  array
     * @since  3.2
     */
    protected $predefinedOptions = array(
        '0'  => 'COM_USERS_ACTIVATED',
        '1'  => 'COM_USERS_UNACTIVATED'
    );

JFormFieldUserGroupList

Shows a nested list of user groups available. Sample use:
usergrouplist

JFormFieldLimitbox

Shows a limit box for pagination. It's like the one generated by JPagination::getLimitBox method but reusable & customisable outside.

The default use is:

        <field
            name="limit"
            type="limitbox"
            class="inputbox input-mini"
            default="25"
            label="COM_CONTENT_LIST_LIMIT"
            description="COM_CONTENT_LIST_LIMIT_DESC"
            onchange="this.form.submit();"
        />

The default values are:

    /**
     * Default options
     *
     * @var  array
     */
    protected $defaultLimits = array(5, 10, 15, 20, 25, 30, 50, 100);

It supports attributes to modify the list of limits used without creating a new field:

  • limits : Manually specify the limits shown. Sample: limitbox_limits
  • append: Append extra values to the default list. Sample: limitbox_append
  • remove: Removes values of the default list. Sample: limitbox_remove

JFormFieldRegistrationDateRange

Show a list of registration date ranges. Values possible:

    /**
     * Available options
     *
     * @var  array
     * @since  3.2
     */
    protected $predefinedOptions = array(
        'today'       => 'COM_USERS_OPTION_RANGE_TODAY',
        'past_week'   => 'COM_USERS_OPTION_RANGE_PAST_WEEK',
        'past_1month' => 'COM_USERS_OPTION_RANGE_PAST_1MONTH',
        'past_3month' => 'COM_USERS_OPTION_RANGE_PAST_3MONTH',
        'past_6month' => 'COM_USERS_OPTION_RANGE_PAST_6MONTH',
        'past_year'   => 'COM_USERS_OPTION_RANGE_PAST_YEAR',
        'post_year'   => 'COM_USERS_OPTION_RANGE_POST_YEAR',
    );

Status

Search tools can be implemented in a lot of places. This is the list of the done/possible managements where it can be/has been implemented:

  • Articles
  • Banner list
  • Banner client list
  • Banner track list
  • Categories
  • Contacts
  • Content language manager
  • Featured articles
  • Feeds
  • Installer: Discover install
  • Installer: Extension manager
  • Installer: Update
  • Menu items
  • Module manager
  • Plugin manager
  • Tags
  • Template manager
  • User list
  • User notes
  • Web links

Future enhacements

The search tools system is in its first stage that means that "it works". In the future we hope:

  • Allow to reload items with AJAX using layouts for rows & allowing to add a refresh URL.
  • Allow to save custom filters by the user
  • Allow to save item count limit to remember the user preferences for each management.
  • Convert the select boxes into a more Google style list.
  • Allow to customise the filters at the template level allowing a fully site customisation (actually it can be done with layouts but it's not the best way to add/change fields).

Credits

Search tools was possible thanks to:

  • Angie Radtke
  • Beat
  • Brian Teeman
  • Peter Van Westen
  • Roberto Segura
  • Seth Warburton

It was possible also thanks to the great Code Sprints concept created by the Joomla! PLT team & sponsored by Open Source Matters.

avatar phproberto phproberto - open - 21 Sep 2013
avatar mbabker
mbabker - comment - 22 Sep 2013

Question - Is there a reason the sort/order and limit boxes have a border?

avatar phproberto
phproberto - comment - 23 Sep 2013

Hi Michael the boxes have the border when they are active but I see what you are talking about. Order an limit are always active so they are going to have a border always. I'll remove it

avatar phproberto
phproberto - comment - 23 Sep 2013

Updated & rebased vs the latest master and removed the borders from the always active select boxes.

avatar phproberto
phproberto - comment - 28 Sep 2013

After the meeting with @dbhurley & @brianteeman we decided to create a branch to be able to test search tools with:

  • Remove sidebar
  • Add category as column
  • Add author's alias as column
  • Increase the size of the small columns to standarize sizes

As we will need to undo some of this changes I only did it for content. Changes are already commited for review.

avatar phproberto
phproberto - comment - 9 Oct 2013

Rebased again vs the latest master

avatar phproberto
phproberto - comment - 14 Oct 2013

Rebased again vs latest master

avatar nicksavov
nicksavov - comment - 15 Oct 2013

Awesome! Thanks for working on this guys!

Looks like it's out of sync with master again. Could you resync it?

Cheers

avatar phproberto
phproberto - comment - 16 Oct 2013

Ok. I fixed the conflicts & rebased this one more time. I also used the new hint attribute (for placeholder) added in the fields improvements

avatar phproberto phproberto - close - 17 Oct 2013
avatar brunobatista brunobatista - close - 17 Oct 2013
avatar MAT978
MAT978 - comment - 17 Oct 2013

THANKS!

avatar phproberto
phproberto - comment - 18 Oct 2013

There are some issues after merge search tools:

  • Undefined constant constant JPATH_0 in language overrides view. ( See #2279 )
  • Remove unused $langs in layouts. (See #2281)
  • Missing translations in menus management ordering field (See #2281)
  • Ordering by associations should not be shown when associations are not enabled (See #2281)
  • Article manager: when selecting a category the Options button dissappear (not a search tools issue). View checks ACL with: $canDo = JHelperContent::getActions($this->state->get('filter.category_id'), 0, 'com_banners');
  • In banner clients you cannot filter by unpublished + monthly. it doesn't filter by status (See #2281)
  • Fix mobile device views (See #2281)
avatar brianteeman
brianteeman - comment - 18 Oct 2013

GReat work - looking forward to seeing this in all managers now

avatar beat
beat - comment - 18 Oct 2013

Nice work, Roberto!

Question: in master branch, In articles manager, I'm still seeing (incorrectly) the left submenu, while it's not on your picture above, which is correct. Was this PR not supposed to remove the left columns where sub-menus are available ?

avatar infograf768
infograf768 - comment - 19 Oct 2013

Commented on new PR
#2281

avatar phproberto phproberto - head_ref_deleted - 19 Oct 2013
avatar phproberto
phproberto - comment - 19 Oct 2013

@beat this PR is only related to search tools. That's how it was decided to make them independent. The hide left menu was going to be in a different PR.

avatar beat
beat - comment - 19 Oct 2013

@phproberto Ok, thought to have read something different but i agree with your answer ofc, but then the PR to remove the side sub-menu got missing somewhere the rebasing to master of these 2 committed PRsĀ ? :

joomla-projects#51
joomla-projects#52

Are you doing a new PR against master for that ?

avatar beat
beat - comment - 23 Oct 2013

@phproberto : Asked @brianteeman to rebase his initial PR for this to master same as JUX team had to do for all their PRs:

joomla-projects#51 (comment)
joomla-projects#52 (comment)

avatar brunobatista
brunobatista - comment - 24 Nov 2013

I try set a default value in populateState, by example:

$year = $this->getUserStateFromRequest($this->context . '.filter.year', 'filter_year', date('Y'));
$this->setState('filter.year', $year);

But in the filters not show the default value, show the select value. Any idea how solve this?

fireshot screen capture 019 - terracap - administrao - gerenciador de licitaes_ imveis - 10_27_133_144_internet_prod_administrator_index_php_option com_biddings view properties

avatar garyamort garyamort - reference | - 2 Dec 13

Add a Comment

Login with GitHub to post a comment