![]() |
|
Adding info text to search box - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: Adding info text to search box (/thread-7447.html) |
Adding info text to search box - makar - 2010-08-09 Hello, I am looking for a way to add informative text to a search box, i.e. a text that is shown there by default and disappears when cursor is put there. I have located the following line in template-functions.php: ` Adding info text to search box - acrylian - 2010-08-09 You should never modify core files. You may want to look at the searchform function (see documentation for the correct name), that has a parameter to change the button text. Adding info text to search box - makar - 2010-08-09 It is text in input rather then the button, that I would like to see. Perhaps I did not explain it well, so for example you can observe it on this site: http://blog.js-development.com Where in the input field there is "Search..." text. I took a look at source of this site and it looks like I will need to modify the core, as I cannot see how to implement this with ZP's function printSearchForm. Adding info text to search box - acrylian - 2010-08-09 Ok, I missunderstood. I suggest to try using jQuery to modify that. Then you would not need to hack the core. If you really need to modify the function itself, copy it, rename it and use it as a theme custom function (see the theming tutorial about that) instead of hacking. Adding info text to search box - makar - 2010-08-09 Looks like this jQuery plugin should do the trick: http://plugins.jquery.com/project/default-text From what I've gathered so far (I am quite new to JS and haven't dealt with jQuery), this example code should work just by including it in the body: ` $('input').defaultText({ defText: 'Bob' }); ` And of course there is in the head: ` Adding info text to search box - fretzl - 2010-08-09 Put this in the head of your page and see if this is what you want. ` // ` Adding info text to search box - makar - 2010-08-09 Oh yes, that is exactly what I wanted! Plus it's quick and simple. Thank you very much for sharing the code! Adding info text to search box - jackdaw - 2012-03-30 I added the above code of fretzl to my header. It works, but after the first search is done, I'd like to add the text 'Search more...' to the input field, so that visitors know they can specify their search even more. How can I do that? Adding info text to search box - acrylian - 2012-03-30 That will most likely be on the search.php itself. You probably need to check for results or empty results to change the text accordingly (that is needed as you technically can access the search page without prior search - depends on your site naturally). Adding info text to search box - sbillard - 2012-03-30 The simplest way to do this would be to change the text in the above script to be a PHP statement Change both instances of Of course this presumes that your them has setup the Adding info text to search box - jackdaw - 2012-03-31 Thanks! It was even simpler than I thought. Just adjusting those lines in the search.php file was enough. Adding info text to search box - Tedsds - 2012-04-05 How can I use the code to populate both the email address field and product search? I've tried it several ways and the text in only 1 field will disappear, while the other stays there. Adding info text to search box - acrylian - 2012-04-05 What a really clever spam attempt...:-( |