Add "submit" button to search bar
dayzero
Joined: 2003-06-15
Posts: 19 |
Posted: Sun, 2004-05-16 05:01 |
How would I go about adding a submit button to the search bar. I'm currently using gallery v1.4.1-pl1 |
|
Posts: 50
I think this is a great idea too, beats hitting enter!. I am not a programmer so I wouldn't know where to start but hopefully someone will read this post and explain how it can be done...
Posts: 12
I'm not running 1.4.1, but the theory should be the same!
In albums.php, have a look for
and add after it
<input type="submit" name="searchsubmit" value="Whatever You Want Your Button To Say">
So mine looks like:
Obviously just change the "Whatever You Want Your Button To Say" to ... well, whatever you want your button to say :wink:
Don't forget to back up albums.php first, just in case anything goes horribly wrong :D
Posts: 50
Excellent JarenTane!
This did the trick, I've added it to my site...
Thanks again-
Mark
Posts: 6
Don't forget to make the same changes in your gallery/search.php Otherwise you will still have the same old search bar on the search results page. My code looks like this around line 70 in search.php and 130 in albums.php
Notice I commented out the words to the left of the search bar, changed the font size to 12, and added &_nbsp;&_nbsp; (obviously the underscore was added because this forum doesn't like html) to leave a space between the search bar and button. Works great, thanks to JarenTane.
Posts: 50
Good thinking P0stman911!
I didn't even spot it until I read your post!, I've made the changes and they look great, one thing though, for some reason the underscore between the ampersand and 'nbsp' wouldn't work for me, I left it out and all is perfect!.
Changing the font size for 'Search again' was a good idea too, would you know how to change the font style from Ariel to Verdana?, it may have something to do with CSS, am unsure?, if I could change this it would help the look & feel of my site all that bit more...
Thanks again for that piece of code & again to JarenTane for the assistance earlier today!.
Regards,
Mark
Ireland
Posts: 6
I'm glad it worked. Just to clarify: the underscores should be removed between the &_nbsp. I added them so I could post the code in this forum otherwise this forum changes it to just an & without the nbsp. Sorry for any confusion.
To change the font family for the text input box simply add font-family: Verdana like this:
<input style="font-size:12px; font-family: Verdana;" type="text" name="searchstring" value="" size="25">
Changing the font family or size for the button is done the same way. Like this:
<input style="font-size:px; font-family: Verdana;" type="submit" name="searchsubmit" value="Search">
I removed the text to the left of the text input boxes: "Search Again:" or "Search:" on album page. But if you want to change the size or family just change this:
<span class="admin"> <?php echo _("Search Again") ?>: </span>
to this:
<span style="font-size:12px; font-family: verdana;"> <?php echo _("Search Again") ?>: </span>
This just seemed easier than working with a seperate css sheet. Don't forget that you'll have to make changes in both the search.php and albums.php There are several other properties of text that can be changed this way. If you are interested check out this page: http://www.devx.com/projectcool/Article/19813 Scroll down a bit to 'Font Properties'
Posts: 50
Hi P0stman911,
The scores on the doors are as follows!.
Firstly thanks again for all your help & support on this for me!...
I made the latest changes to search.phpand got my 'Search results\Search Again' page looking great, everything is in order, the fonts, the submit button the whole thing is great! however it was quite the opposite when I tried to modify albums.php!. There are a couple of things and it may be my fault!... the following code doesn't exist in albums.php only search.php (if it does I coudn't find it!):
<span style="font-size: 12px; font-family: verdana;"> <?php echo _("Search Again") ?>: </span>
(I modified the above in search.php and all is great...)
I did however find the following in albums.php:
echo '<span class="search">'. _("Search") .': </span>';
echo '<input style="font-size: 12px; font-family: verdana;"> " type="text" name="searchstring" value="" size="20">&<input type="submit" input style="font-size: 12px; font-family: verdana; "> "name="searchsubmit" value="Go!">';
echo '</form></td>';
As you can see I tried to make some changes to it figuring that this was the right section of code however I only got as far as entering the font type above and next thing when I refreshed my Gallery page it all went pear shape!. When I load my Gallery page I now get the following error:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/html/gallery/albums.php:1) in /var/www/html/gallery/session.php on line 52
All is not lost as I mad a backup copy of my albums.php file before I went playing around with the code...
As I said I most likely did something myself!...
If you get a chance you may be able to tell me where I'm going wrong...
Once again I appreciate it...
P.S. Thanks also for the devx.com reference, it's very informative.
Regards,
Mark
Ireland
Posts: 6
Sorry about that, I hadn't looked at albums.php but it is very similar. Starting around line 125 of albums.php you should see something like this:
Changing the font for the search box and the button are done exactly the same as in search.php just add
style="font-size:12px; font-family: Verdana;"
and so on, after the<input
To change the text to the left of the search box, in this case "Search", In album.php change this:
to something like this:
Worked when I tested it. In my experience most errors occur because there was a single " or ' or ; left out. I'm not sure why your getting yours but obviously it has something to do with what you edited. Try the above code, it should work great. Don't forget to remove the underscores in the &_nbsp :D
Posts: 50
Hi P0stman911,
Thanks for not giving up on me!, I've spent the last couple of hours tinkering with the latest code you posted and made sure I had done everything correctly before I bothered you again!.
With the exception of changing the font for 'Search:' on the first search page I have everything working just fine. I think I realise now why I can't change this font, it appears that my code and your code are slightly different when it comes to implementing the code required to change the 'Search:' font.
Below is a copy of my code (all of this begins on line 104 of albums.php.
}
if ($numPhotos != 0) {
echo '<td valign="middle" align="right">';
echo makeFormIntro('search.php', array(
'name' => 'search_form',
'method' => 'post'));
echo '<span class="search">'. _("Search") .': </span>';
echo '<input style="font-size:11px; font-family: Verdana;" type="text" name="searchstring" value="" size="20">&<input type="submit" input style="font-size:11px; font-family: Verdana" name="searchsubmit" value="Go!">';
echo '</form></td>';
}
?>
The code I have highlighted in bold differs slightly from your code which (I think!) represents the same function?...
Your Gallery code:
<span class="search"> <?php echo _("Search") ?>: </span>
From looking at this would you know what I need to do?...
Hopefully this will be the last time!...
Thanks again...
Mark
Posts: 6
Just out of curiousity what Gallery version are you using?
Try changing this:
echo '<span class="search">'. _("Search") .': </span>';
to this:
echo '<span style="font-size:12px; font-family: Verdana;">'. _("Search") .': </span>';
I noticed you have added an extra 'input'. I think the following code should work:
Hopefully this will have the desired effect. Good luck. :D
Posts: 50
Excellent P0stman911! - it works like a charm!.
Thanks again, I really appreciate all your help & support on this one...
P.S. I'm using Gallery v1.4.4-cvs-b103 (I'm guessing this is why my line of code differs to yours?)
Thanks again...
Cheers!
Mark :D