Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Alphamenu on collection 04 Jun 2012 09:06 #2474

  • albert
  • albert's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 70
  • Thank you received: 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

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

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

  • etc
  • etc's Avatar
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 132
  • Thank you received: 19
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.

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

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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 following user(s) said Thank You: JoomGuy

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

  • Page:
  • 1
Time to create page: 0.102 seconds

The j-cook project is indeed one of the best tools I've run across for building Joomla components and the beta version should make things even better!

dyoungers (Forum)  

Get Started