[All Adaptavist Apps]

Page tree

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

A fairly common request from customers is to customise the search button that's output by the search-box macro...

Adding a Search Box

The [search-box macro] is part of Adaptavist's open source "Content Formatting Macros" plugin:

{search-box}

It appears top-right (most common place for a search box) on almost every theme we develop (it's part of the DEFAULT theme layout) but can easily be moved to other panels or even put in to page content.

While the default search button is fine for most customers, some want a graphical button instead. Here's an example:

Image

First, you'll need the graphical image, for example:

Unknown macro: {menuicon}

Wherever possible, use a GIF or JPG image - it's going to be a background image meaning that Internet Exploder versions earlier than 7.0 won't display transparency properly (even with our PNG fix script because it only looks at <img> tags).

If you do use a PNG then you'll have to use the MSIE proprietary alpha transparency filter in your CSS (I'll leave you to google for more info on that to deter you using it ).

If the site doesn't allow anonymous access, remember that images attached to pages won't be available to logged out users (eg. on login, forgot password and sign-out screens) so you might need the image placing in the /images folder on disk or find some other location for it.

CSS

The CSS is pretty simple:

/* search box */
.searchButton {
 border-style: none;
 text-indent: -10000px;
 overflow: hidden;
 background: transparent url(/download/attachments/2261005/go.jpg) no-repeat scroll top left;
 width: 20px;
 height: 20px;
 cursor: pointer;
}

When any CSS is applied to a HTML form element, the browser takes over its rendering (normally it lets the operating system do the rendering).

The CSS above does the following:

  • removes border
  • hides the text (by adding a negative indent and hiding the overflow)
  • removes the default background color and applies an image background instead
  • Sets a fixed width and height (same dimensions as the image)
  • Displays a pointer cursor when the mouse is over the button (so user knows it's clickable)

You'll notice that a relative URL has been used - this is of critical importance as most sites (including 100% of sites we host for customers) can be accessed from multiple URLs and cross-domain security will prevent background images (depending on browser and config) if they are from a different domain.

If you're using CSS sprites, remember to set the pixel value position of the relevant sprite on the background style.

Using Builder Icon Resources

If the customer is using Theme Builder 3.0.3 or above, you can use any of Builder's icon resources in the CSS, with an un-documented feature:

 background: transparent url(%ICONPATH%/view.gif) no-repeat scroll center center;

It's possible the %ICONPATH% property will get renamed to something more inline with other properties (eg. Confluence colour properties) so discuss with [~gfraser] before using this trick.

  • No labels