473,322 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Has anybody tried to make a navigation like Google?

Lad
Hi,
I would like to make in my web application a similar navigation like
Google uses, I mean at the bottom of each page there are numbers of
returned pages after you search query.
Has anyone tried that? Is there an algorithm for that? I do not want to
re-invent the wheel.
Thank you for help
La.

Sep 5 '05 #1
3 1340
Lad enlightened us with:
I would like to make in my web application a similar navigation like
Google uses, I mean at the bottom of each page there are numbers of
returned pages after you search query. Has anyone tried that? Is
there an algorithm for that? I do not want to re-invent the wheel.


Isn't that just dividing the number of results by the number of
results per page? That would give you the number of pages...

Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa
Sep 5 '05 #2
Lad wrote:
Hi,
I would like to make in my web application a similar navigation like
Google uses, I mean at the bottom of each page there are numbers of
returned pages after you search query.
Has anyone tried that? Is there an algorithm for that? I do not want to
re-invent the wheel.
Thank you for help


I did something like that recently.

http://www.foodfileonline.com

Its not so complicated, you just need to know how many search results
you have returned and how many are shown on each page. You will also
need a search page that can start at a particular position in the results.
Will McGugan
--
http://www.kelpiesoft.com
Sep 5 '05 #3
Lad wrote:
Hi,
I would like to make in my web application a similar navigation like
Google uses, I mean at the bottom of each page there are numbers of
returned pages after you search query.
Has anyone tried that? Is there an algorithm for that? I do not want to
re-invent the wheel.
Thank you for help
La.

First the assumptions:

* We'll assume you're using SQL queries against a database
* You don't want to have to produce the whole result-set across the
database interface, but you don't mind producing them on the
database side
* You want precise values (Google's aren't precise measures of
number of records)
o If you don't, you can use whatever estimation mechanism you
like to get the total instead of a second query
* You have a complete ordering of records (if not then your results
will randomly shuffle themselves as the user pages through)

Given that:

* You need to construct a query that produces (just) a count of all
records in the set
* You then need a query that is parameterised to return a subset of
the records in the set
o offset -- count of records from the start of the set
o limit -- number of records to display on any given page

Now, when you want to retrieve the records:

def search( self ):
"""Perform the search, retrieve records and total"""
self.records = self.SEARCH_QUERY(
connection,
whatToSelect = self.whatToSelectSubset,
limits = self.calculateLimits(),
orders = self.calculateOrders(),
wheres = self.calculateWheres(),
**self.queryParameters
)
for record in self.SEARCH_QUERY(
connection,
whatToSelect = self.whatToSelectCount,
limits = "",
orders = "",
wheres = self.calculateWheres(),
**self.queryParameters
):
self.total = record[0]

In that code the SEARCH_QUERY is a PyTable SQLQuery object, it just
takes care of the cross-database substitution operations. The code to
handle the whatToSelect determination looks like this (by default):

keyColumnName = common.StringProperty(
"keyColumnName", """Column name used to count total number of
columns""",
#define keyColumnName on Search!,
)
whatToSelectSubset = common.StringProperty(
"whatToSelectSubset", """What to select in the subset-of-records
query""",
defaultValue = "*",
)
whatToSelectCount = common.StringProperty(
"whatToSelectCount", """What to select in the count-of-records
query""",
defaultFunction = lambda prop,client: """COUNT(DISTINCT( %s
))"""%(client.keyColumnName),
)

the wheres are the natural WHERE clauses you want to apply to the query
(i.e. the search terms). The orders are normally a default set of
fields with the ability for the user to move any field to the front of
the set via UI interactions. The "limits" are actually both limits and
orders in this example, since they are tied together as the paging
functionality:

def calculateLimits( self ):
"""Calculate the limit/offset clauses for a select"""
return """LIMIT %s OFFSET %s"""%( self.limit, self.offset )

Just for completeness, here's an example of a SEARCH_QUERY:

SEARCH_QUERY = sqlquery.SQLQuery("""SELECT
%(whatToSelect)s
FROM
voip.voicemail JOIN voip.voipfeature USING (voipfeature_id)
JOIN voip.voipaccount USING (voipaccount_id)
%(wheres)s
%(orders)s
%(limits)s
""")

The UI then offers the user the ability to increase offset (page
forward), decrease offset (page backward), and re-sort (change the
ordering fields). You disable the paging if you've reached either end
of the record-set (offset<0 offset >= total-1), obviously.

Anyway, hope that helps,
Mike

--
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com

Sep 5 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tom Jordan | last post by:
Hi guys, I'm using the Webedit Pro CMS for a client. When the user creates a new page, rather than go through every other page in the site and add a new link to the left hand navigation I want...
22
by: Marek Mand | last post by:
How to create a functional *flexible* UL-menu list <div> <ul> <li><a href=""></li> <li><a href=""></li> <li><a href=""></li> </ul> </div> (working in IE, Mozilla1.6, Opera7 (or maybe even...
67
by: Sandy.Pittendrigh | last post by:
Here's a question I don't know the answer to: I have a friend who makes very expensive, hand-made bamboo flyrods. He's widely recognized (in the fishing industry) as one of the 3-5 'best' rod...
4
by: Sandy.Pittendrigh | last post by:
I don't want to get into a frames discussion here. We all know they have numerous drawbacks, especially with search engine visibility. (Google, ironically, uses framesets for displaying individual...
28
by: laredotornado | last post by:
Hi, Surprisingly, I can't get the drop down menus to work on PC IE 6. If you roll over "PRODUCTS", normally a drop down menu appears (on Safari and Firefox), but on PC IE, nada. ...
2
by: Mirovk | last post by:
Hi, I would like to disable the navigation bar in IE to force my web users to use the application´s navigation buttons. Ideas welcome, Thanks...
4
by: (PeteCresswell) | last post by:
"Pages" as in the web page UI to an MS Access back end. Just had a lunchtime discussion with a couple of co-workers and none of us have been able to actually use a "Page".... but our experiences...
3
by: Gary | last post by:
Afternoon Is it possible to display test alongside the Navigation Buttons in an MS Access form? I have a complex form containing a number of subforms where the Navigation Buttons are...
2
by: Chris | last post by:
Is there a way to remove the navigation bar when the webpage is displayed in full screen F11. I don't have anything that needs scrolling so I don't need it to show. Thanks, Chris
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.