Welcome, Guest
Username: Password: Remember me

TOPIC: Alphamenu on collection

Alphamenu on collection 04 Jun 2012 09:06 #2474

  • albert
  • albert's Avatar
  • Offline
  • Senior Member
  • Posts: 70
  • Thank you received: 2
  • Karma: 2
Hi,

I would be interested into create an alphamenu on the top of the collection of items on the frontend.
[ALL | A | B | C | D | .... ]
Anyone know how to implement it ?

thanks in advance
The administrator has disabled public write access.

Re: Alphamenu on collection 05 Jun 2012 08:27 #2482

  • etc
  • etc's Avatar
  • Offline
  • Premium Member
  • Posts: 132
  • Thank you received: 19
  • Karma: 7
Hi,

At the first glance I would see two possibilities.
First is to play with filtering, whether there is a way to customize it.
One of the files you can find in tmpl folder in case you used this in Cook Builder and others you will find in JDom (search).

The second is to create own module which will display alphamenu pattern.
It would just run simple sql query to display data that you need.

So this is just my idea what I would try to do.
The administrator has disabled public write access.

Re: Alphamenu on collection 05 Jun 2012 08:53 #2483

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Yes,

In both cases you should customize the search query.

Example for D letter :
SELECT * FROM #__xxx WHERE name REGEXP '^d';

So, all you have to do is to add some code in : classes/jmodel.list.php :
function _buildSearch(...)
{
	if (!isset($this->_searches[$instance]))
		return;

	$db= JFactory::getDBO();
	$tests = array();
	foreach($this->_searches[$instance] as $namespace => $search)
	{
		$test = "";
		switch($search->method)
		{
			case 'like':
				$test = $namespace . " LIKE " . $db->Quote("%%s%");
				break;

			case 'exact':
				$test = $namespace . " = " . $db->Quote("%s");
				break;


			//ADD HERE
			case 'startwith':
				$test = $namespace . " = " . $db->Quote("^%s");
				break;

			//END

			case '':
				break;
		}

		if ($test)
			$tests[] = $test;
	}

...

So, where _addSearch() is called, change the search method name (you'll find this ;-) )


To finish, call your page adding in the url : &search_xxxx=D (example)



Not tested,
Try it and please furnish the working solution.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: JoomGuy
Time to create page: 0.075 seconds

Get Started