Have you ever wondered how the “Most Visited” bookmarks folder included with Firefox works? It’s not just a special-cased folder – it takes advantage of the Places database introduced in Firefox 3, and you can create your own smart bookmarks.
Firefox’s Places system stores your bookmarks and history in an SQLite database. Firefox includes a powerful query: syntax for working this this database, but this feature is all but hidden by default.
Saving a Search
Firefox exposes a single way of creating a smart folder by default. To get started, open the Library window by selecting the Bookmarks or History option in the menu.
Perform a search using the search box in the Library window. You can search both page titles and page URLs – for example, type “How-To Geek” to find all pages with How-To Geek in their title or type “howtogeek.com” to find all pages on the How-To Geek website.
You can have the smart bookmark search your bookmarks or history. After selecting Bookmarks or History, click the Save button and provide a name to save your search as a smart bookmark folder.
Firefox creates the bookmark folder in your bookmarks menu by default, but you can place it anywhere you like – for example, on your bookmarks toolbar.
Firefox automatically updates the smart bookmark folder – it’s just a database query, like a smart playlist in iTunes. If you’ve been following along, you now have a smart bookmark folder that displays the pages you’ve recently visited on How-To Geek.
Using an Extension
To get at the advanced functionality, you can write places URIs yourself – but most users will probably want an easy-to-use graphical interface. Mozilla doesn’t provide one, so you’ll have to install an extension like SearchPlaces.
After you install the extension and restart Firefox, you’ll see a new SearchPlaces option in your Bookmarks menu.
SearchPlaces provides a graphical interface for creating new smart bookmarks and editing existing ones. It exposes much of the power left out of Firefox’s default interface.
SearchPlaces offers a lot of options for constructing your Places URI. For example, here we’re searching for pages containing the word “Android” that have been visited between 10 and 20 times. We could also specify a time range the web pages were visited between, although this is a bit complex to do – you have to specify a number of seconds from a relative time.
However, you can easily specify “today” as a time range. Set the relative time to “Midnight this morning” and enter “0” as the time.
To edit a smart bookmark folder that comes with Firefox, select it and click the Edit button.
SearchPlaces shows you each smart bookmark’s place: URI. Firefox hides these in the default interface – presumably to avoid scaring inexperienced users.
Writing Places URIs
Mozilla provides a detailed guide to place: query URIs on the Mozilla Developer Network website. There are a wide variety of options that you can use to construct complex query URIs.
For example, let’s say we want to create a smart bookmark folder showing all the pages we’ve visited on How-To Geek today, sorted in alphabetical order. This is the query string we’d use:
There are four parts to this query:
- terms=howtogeek.com – Searches for the term “howtogeek.com”.
- beginTimeRef=1 – The begin time is relative to midnight this morning.
- beginTime=0 – The “0” is a special value that includes all results since the relative time. In this case, it matches all results since midnight this morning – that is, all pages visited today.
- sort=1 – Orders results in alphabetical order.
Once you have a query URI, create a new bookmark from the Library window or Bookmarks menu.
Name the bookmark and use the place: URI as the bookmark’s address.
Due to an apparent bug, you can’t create a smart bookmark directly on the browser toolbar. Firefox will treat it like a normal bookmark instead of noticing the place: URI and treating it properly.
Create it elsewhere – such as in your bookmarks menu — and drag and drop it onto the toolbar. Firefox will notice it’s a smart bookmark.
Firefox’s Places database hides a lot of power – it could be a killer feature for some people, but most will never notice it’s there.