Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Styling a search box

From: Joomla! 1.5: Styling with CSS

Video: Styling a search box

One of the great features that Joomla! comes with is a built-in search function. I am going to show you how you can get this in to your website and some of the options that you have for the search bar. Then I am going to show you how to make it a little bit prettier. It definitely looks functional right now but I think, we can liven it up a little bit to better blend in to the look and feel of this website. So I am going to start by going to the back end of my website and I am going to go Extensions > Module Manager, under Search in the Module Manager, if you click on that, we will be editing the search module. Like all modules on the left hand side of the page, you can set things like the title, whether or not you want that title to show, whether it's turned on and the position on the page you want it to appear, as well as which pages you would like it to appear on.

Styling a search box

One of the great features that Joomla! comes with is a built-in search function. I am going to show you how you can get this in to your website and some of the options that you have for the search bar. Then I am going to show you how to make it a little bit prettier. It definitely looks functional right now but I think, we can liven it up a little bit to better blend in to the look and feel of this website. So I am going to start by going to the back end of my website and I am going to go Extensions > Module Manager, under Search in the Module Manager, if you click on that, we will be editing the search module. Like all modules on the left hand side of the page, you can set things like the title, whether or not you want that title to show, whether it's turned on and the position on the page you want it to appear, as well as which pages you would like it to appear on.

On the right hand side of the page, there is a number of great features that really lend themselves well to styling. First of all, you can change the Width of the box, the actual search box itself. By default, this is set to 20 pixels but you can change it to whatever you like. The Text box is what appears in the search text box. If it's left blank, it loads what's called the search box string from your language file. In this case, flipping back to the front on to the website, that's search... If we want something else, we can say find it here, for example. If we apply that and flip back to the front end of the website, you will see the text in the box has changed.

The Search button is that button to the right hand side. Because I have that button turned on and the Position set to Right for that search button, you don't have to have it, but I would recommend it because I think, many users feel lost, when there is no button on their search box. You can also set your Search Button to be an image, simply by setting the Search button option to Yes and then follow the directions very carefully in the balloon. The image must be named, search Button. That's lowercase search, capital b, searchButton.gif and it has to be located inside of the images/m_imagesdirectory.

So once again, this is a case of Joomla! being very particular about what it wants for things to work correctly. If you are going to include a Search Button, you can change the button text as well. Once again, by default it's loading the word, search, but I am going to change my Button Text to Go and I am going to take out this text that I put in here a little earlier and say Apply. I don't like it to say search... and then have the search button itself say search as well. I think, it's a little redundant. So now it says, search...

and then Go. Once you click in the box, that text will go away. Under the Advanced Parameters, there is some caching options that you probably will never need to change, but they are there, in case you do. Note also that there is this module Module Class Suffix as we have seen on other modules. So if you need some way of differentiating the search module from other modules in a similar area, the Module Class Suffix may be helpful to do that. Let's save our changes and now we can worry about styling our search box. I am going to refresh my page and now I am going to view the HTML. I am going to take a look at the top of the page for this line here, where we have a div with an id of search and inside of this div, there is two things, one is the tag line, this, enter a new dimension of good taste and that's followed by a div with a class of moduletable, which is the actual search functionality itself.

There is a form, another div with a class of search, and then the search input box itself and then the search button, which has a class of button. We will want that later because I am going to try to style that button a little bit differently than that gray looking button that we have now. Now that we know what the HTML looks like, let's write some CSS. Under CSS > Edit CSS, under default.css, let's find the search piece, which is here under the #headcontainer and their elements. There is a div here for search with its styling. So the first thing I am going to add is a div.moduletable because I would like to add some padding. Our search is smashed right into the very edge of the webpage. What it's like is for the edge of the button to align up with the e in taste. So we will put in some padding and we may need to adjust it, once we have modified our button, a little bit. 7 pixels on the top, 15 pixels on the right. Now I am going to work on that button here.

So inside of the div.moduletable, we are going to work with an input with a class of button. That will help differentiate it from the input that drives the search box. First of all I would like the color of the text to be white. I want the background to be that pink color. Although that border really detracts from the button, so let's get rid of that. I think, I would like to make the word, Go, uppercase and I would like it just a little bit smaller too. When you change the font size of the button, you may have noticed that the button itself shrink in size. That's a common occurrence with these buttons.

The next thing that we are going to do is change that search box to have a matching font size, so that the height of the search box and the height of the button are the same. Now let's add a little bit of breathing room between the button and the search box by putting in a margin on the left. Now let's concentrate on that search box. So once again, div.moduletable input and that search box is assigned an id of #mod_ search_searchword. Let's turn the border off and we need to reduce the font size, so that matches the size of the button. Once again, I am going to give it a little bit of margin as well.

So our search box has shaped up very nicely. Now I am going to copy and paste all of the CSS changes into my Joomla! template. So once again, Ctrl or Command+A, Ctrl or Command+C to select all of the text and copy, back to the back end of the website, under Extensions > Template Manager, under inside, Edit, under Edit CSS, default, Edit, Ctrl or Command+A to highlight everything, Ctrl or Command+V to paste, and save.

Now when I refresh my webpage, I have a great looking search box and that really enhances the look of the website. Once again, the search box is an extremely handy addition to any Joomla! website, particularly those of a larger size. Search boxes are becoming common on lots of websites and they are in demand with a lot of clients. It's so easy to add a search box to your Joomla! website. So you may consider adding one as well.

Show transcript

This video is part of

Image for Joomla! 1.5: Styling with CSS
Joomla! 1.5: Styling with CSS

22 video lessons · 15910 viewers

Jen Kramer
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Joomla! 1.5: Styling with CSS.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.