smartwebstudio.com

 

K2 Extra fields Filter and Search
Module for Joomla

latest version: v 0.92 (28-Feb-2o1o)

Table of Contents

Description

K2 Extra fields Filter & Search is a module for content management system Joomla 1.5.x and content construction kit K2.

I decided to write the code myself for one of my projects as the functionality to filter and search extra fields in K2 is missing and I didn't wanted to use tags to do it. Besides lot of users were asking on the forums for such thing and I felt that I can prepare the ground for other developers and users to discuss other required functions (at the moment module has limited capabilities) and contribute.

In my opinion it's essential to have such functionality when one wants to implement K2 for projects that uses directory listing (catalogs).

Module is compatible with Joom!Fish 2.0.4 (and future versions hopefully).

Module works with Joomla SEF on.

Unfortunately I haven't found any way to provide the functionality I was looking for solely using Joomla module, thus I had to add another listing method 'filter' to the K2 core. You will have to overwrite some of K2 files to use the module.

The drawback are:

If you find module helpful, you may support my work by donating small amount. This is the recognition of work I have done so far and when you do so it doesn't mean that I'll add new functionality for you, fix existing bugs and so on. I hope the K2 community and original developers of the K2 component will help out but I might (or not) do so as well depending on my spare time.

Please post your comments in the forum and let's see what we can achieve together!

What does the module do?

As the name states, you may use it to filter out and list your items by specified extra field.

Module works in 2 modes:
  1. When used in selectable mode (Drop-down selection, Multi select list or Radio buttons) module displays available options, which you may filter out and then list the items.
  2. When used a text input (Text field), you can input keyword to search for in the selected extra fields.

What module cannot do at the moment?

License

Code is released under GPL3.

Requirements

Installation instructions

  1. backup your site!
  2. install the module just like any other
  3. overwrite K2 core files by provided ones in folder /components/com_k2/

Upgrading

  1. backup your site!
  2. install new version of module over the old one (or manually overwrite files)
  3. overwrite K2 core files by provided ones in folder /components/com_k2/

Uninstalling

Uninstall the module like any other. If you want to restore original K2 component files, overwrite them back with original K2 2.1 component files.

Documentation

Users

Module parameters

K2 Extra fields Filter and Search module administration Module Class Suffix
just as you know it
Only selected Extra fields
Yes: will filter/ search only for selected Extra field
(example: search for real estate in city X; Extra field City: X, Y, Z)
No: will show results for all extra fields
(example: search for guys who speak Spanish; extra field Language 1: English, extra field Language 2: Spanish, extra field Language 3: other)
Restrict to specified category
If you want to filter/ search only in specified category
Category
If previous parameter set to yes, select the category to filter/search in
Results in all languages
Yes: If Joom!Fish installed you'll get results from all languages
Filter type
Type of filter shown in the module.
It doesn't have to be linked to your Extra fields type, but remember that if in K2 it's a Text field, Text area or Link, it doesn't make sense to use anything else the Text field again here.
On the other side, you can use Text field to search in the selectable type (Drop-down selection, Multi-select list, Radio buttons).
Select Extra field
On what you want to perform filter/ search.
other options (Search box size, etc)
just like in the K2 Tools module.

Example

Let's say you want an option on your web to filter out items according to place.

  1. in K2 component create Extra field 'City' as drop-down selection and add options (i.e. Český Těšín, Katowice, ...)
  2. in K2 Filter and Search module choose 'Filter type': drop-down selection (but can be any option)
  3. in 'Select Extra field' choose 'City' and Save!
Simple, isn't it? ;)

View Overrides

If you want to change the way your module looks like in the frontend, copy files from /modules/mod_k2_filter/tmpl/ to __your_template__/html/mod_k2_filter/ folder and play around with them.

Resources: Joomla.org > Understanding Output Overrides in Joomla! 1.5

Developers

Most important files are:

Component overwrite

(folder /components/com_k2/)
note: all added code is specified by marks
// ADDED K2FSM from here ->>
// <<- ADDED K2FSM till here

models/itemlist.php:

views/itemlist/view.html.php

views/itemlist/view.feed.php

sef_ext/com_k2.php

Module body:

(folder /modules/mod_k2_filter/)

includes/filtermethod.php

At beginning I've tried to use modification of K2 Tools module in search mode, but found it insufficient. Part of that is incorporated the module.

code moved to models/itemlist.php since v0.9

helper.php

contains functions:

Troubleshooting

Module doesn't work! The results page is blank or it is showing name of the section
You didn't overwrite K2 core files. Check out the Installation instructions.

I cannot see changes made in the module configuraiton
clean your Joomla cache in Joomla menu > Tools > Clean Cache

Module is still not working!
Make sure that module is enabled. Play around with settings: switch some on and off. There might be bugs in the functionality. If you are sure that the things are not working as they should, post a reply on the K2 community forum.

In module parameters I'm getting warning like “Warning: Invalid argument supplied for foreach() in ..\libraries\joomla\html\html\select.php on line 68”
K2 component is not installed

Issues, Known bugs & Todo

sh404SEF: not tested yet, I'd like to add modifications for that later on

Download

Please read the Installation instructions or Upgrading first!

v 0.92 for K2 v2.2

28-Feb-2o1o

Module: mod_k2v2.2_filter_0.92.zip
(MD5: c8d9ba942d7c066f634136c026417760)

K2 component files to overwrite: com_k2v2.2_filter_overwrite_0.92.zip
(MD5: b773760585004e7e210561313d5acf33)

v 0.91c for K2 v2.1

2o-Dec-2oo9

Module: mod_k2_filter_0.91c.zip
(MD5: e1c2db9af50fcc9d0ea078dc0f31419b)

K2 component files to overwrite: com_k2_filter_overwrite_0.91c.zip
(MD5: a1e29813b0f5e5bb462a8af8d62934ec)

v 0.91b for K2 v2.1

o5-Dec-2oo9

Module: mod_k2_filter_0.91b.zip
(MD5: 2f01b58cbb70b5c651d17efdae58a174)

K2 component files to overwrite: com_k2_filter_overwrite_0.91b.zip
(MD5: a1e29813b0f5e5bb462a8af8d62934ec)

v 0.9b for K2 v2.1

o1-Dec-2oo9

Module: mod_k2_filter_0.9b.zip
(MD5: a318da089de6a06d8e5ee1b0a1188833)

K2 component files to overwrite: com_k2_filter_overwrite_0.9b.zip
(MD5: 7c7ae81d1725a1a9b69fa00d68685874)

Restoring

original K2 2.2 component files: com_k2v2.2_filter_originalfiles.zip
(MD5: b9f269077abf54c62e9ee71ed476fd81)

original K2 2.1 component files: com_k2_filter_originalfiles.zip
(MD5: 5530886d170f2a5e6d88aa24ac608ca8)