#1 December 11, 2015 9:19am

Sand
Member
Registered: December 11, 2015
Posts: 3

Alphabetical Navigation and Pagination

Hi, I'm exploring BigTree CMS for couple of days and now trying to create a module which will display Staff Directory List in the front-end with the support of alphabetical navigation and pagination like the following URL:
https://www.concordiacollege.edu/direct … ces/all/1/

Taking DemoTrees module as an example I created a module along with a routed template to display Staff Directory List, this is working fine but not sure how to add alphabetical navigation and pagination functionalities in it.
Any example or a sample code will be very helpful for me. Can anyone please help me in this regards?

Offline

#2 December 11, 2015 10:20am

Sand
Member
Registered: December 11, 2015
Posts: 3

Re: Alphabetical Navigation and Pagination

Okay... finally I managed to add pagination (It's defined in the BigTreeModule class) . Hope alphabetical navigation could be done in the same way.

Offline

#3 December 11, 2015 3:21pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 978

Re: Alphabetical Navigation and Pagination

Here's some sample methods for the module class for letter-based picking:

		function getLetters() {
			$available = array();
			$q = sqlquery("SELECT DISTINCT(SUBSTR(last_name,1,1)) AS `letter` FROM faculty_directory");
			while ($f = sqlfetch($q)) {
				$available[] = strtoupper($f["letter"]);
			}
			sort($available);
			$this->Available = array_unique($available);

			$list = array();
			foreach (range("A","Z") as $letter) {
				$list[$letter] = in_array($letter,$available);
			}
			return $list;
		}
		
		function getByLetter($letter) {
			$items = array();
			$q = sqlquery("SELECT * FROM faculty_directory WHERE last_name LIKE '$letter%' ORDER BY `last_name` ASC, `first_name` ASC");
			while ($f = sqlfetch($q)) {
				$items[] = $this->get($f);
			}
			return $items;
		}

Offline

#4 December 12, 2015 2:03am

Sand
Member
Registered: December 11, 2015
Posts: 3

Re: Alphabetical Navigation and Pagination

Thanks! This is what I was looking for.

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.