Im trying to create my own custom search bar and button, similar to the one on the top of this theme but in a block.
I want to put it in a Top Block so its going across the top of my page.
What is the Code for a php search bar and button?
I am using TP beta4 and 1.1.11... but im not going to use it for that version i want it to work when i upgrade to 2.0
This is the code form index.template.php
echo'
<form id="search_form" style="margin: 0;" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<input type="text" name="search" value="" class="input_text" />
<input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
<input type="hidden" name="advanced" value="0" /></div>';
...but when trying to save it to a php block, it takes me to the results page instead.
Oh didnt know u was a memeber here also.
Yeah i have tried it also it dose the same for me.
What i am trying to do is have the search bar in a HTML table
or a PHP table with the search bar in, but i dont know how to code in PHP
here is what i am trying <table background= "http://spursnetwork.com/images/bar-bg.png" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%"><img src="http://spursnetwork.com/images/left-end.png" width="9" height="36" align="left"></td>
<td width="44%"><?php echo
</div>
<div class="news normaltext">
<form id="search_form" style="margin: 0;" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<input type="text" name="search" value="" class="input_text" />
<input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
<input type="hidden" name="advanced" value="0" /> ?></td>
<td width="10%"> </td>
<td width="44%"><!-- AddThis Button BEGIN -->
<div align="right"><a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&pub=xa-4b0e9d1854bb7905"><img src="http://s7.addthis.com/static/btn/v2/lg-bookmark-en.gif" alt="Bookmark and Share" style="border: 0pt none;" height="16" width="125"></a><br>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pub=xa-4b0e9d1854bb7905"></script>
</div>
<!-- AddThis Button END --></td>
<td width="1%"><img src="http://spursnetwork.com/images/right-end.png" width="9" height="36" align="right"></td>
</tr>
</table>
but when i try the search results i get a server error
im trying to get something similar to this in a top block
You can't do PHP like that in a block when you open PHP tags. You have to close and open them as if you are putting it inside another php block. Try this code:
?>
<table background= "http://spursnetwork.com/images/bar-bg.png" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%"><img src="http://spursnetwork.com/images/left-end.png" width="9" height="36" align="left"></td>
<td width="44%"><?php echo
</div>
<div class="news normaltext">
<form id="search_form" style="margin: 0;" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<input type="text" name="search" value="" class="input_text" />
<input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
<input type="hidden" name="advanced" value="0" /> ?></td>
<td width="10%"> </td>
<td width="44%"><!-- AddThis Button BEGIN -->
<div align="right"><a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&pub=xa-4b0e9d1854bb7905"><img src="http://s7.addthis.com/static/btn/v2/lg-bookmark-en.gif" alt="Bookmark and Share" style="border: 0pt none;" height="16" width="125"></a><br>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pub=xa-4b0e9d1854bb7905"></script>
</div>
<!-- AddThis Button END --></td>
<td width="1%"><img src="http://spursnetwork.com/images/right-end.png" width="9" height="36" align="right"></td>
</tr>
</table>
<?php
However, it looks like your search form is not complete. You're missing some other code I'm sure as there is no ending </form> tag.
interesting bit of code there ..
Thanks for that Inchbin, it working in a php Block now. but the search isn't. I think your right there's something wrong with the search form, but i have no idea how to fix it.
I just copied that code from index.template.php on default theme on rc2 where it has the search bar on the right hand side.
the error i get when i try to search is this
QuoteNot Found
The requested URL /forums/', $scripturl, ' was not found on this server.
any idea how i can fix it or get the correct form
might need that >> global $context, $settings, bit added ?
AH i got it working.
i added the action Link into action="',
now its
?>
<table background="http://spursnetwork.com/images/bar-bg.png" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td width="1%"><img src="http://spursnetwork.com/images/left-end.png" align="left" height="36" width="9"></td>
<td width="44%">
</div>
<div class="news normaltext">
<form id="search_form" style="margin: 0;" action="http://spursnetwork.com/forums/index.php?action=search2"', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<input type="text" name="search" value="" class="input_text" />
<input type="submit" name="submit" value="Search" class="button_submit" />
<input type="hidden" name="advanced" value="0" /></td><td width="10%"> </td>
<td width="44%"><!-- AddThis Button BEGIN -->
<div align="right"><a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&pub=xa-4b0e9d1854bb7905"><img src="http://s7.addthis.com/static/btn/v2/lg-bookmark-en.gif" alt="Bookmark and Share" style="border: 0pt none;" height="16" width="125"></a><br>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pub=xa-4b0e9d1854bb7905"></script>
<!-- AddThis Button END --></td>
<td width="1%"><img src="http://spursnetwork.com/images/right-end.png" align="right" height="36" width="9"></td>
</tr></tbody>
</table>
You didn't need to change the action. You just needed to add this line at the top of your block before the ?> tag.
global $context, $scripturl;
I'd remove the hard code url you put in there and add the line above to your code. Otherwise you'll be getting errors in your log too.
i get the error again when i do that
Which error? Can you post your code? Kind of hard to help if you don't provide any info.
The same one as i got before
QuoteNot Found
The requested URL /forums/', $scripturl, ' was not found on this server.
i posted the code i'm using a few posts before. Then you mentioned that i should not have the action link there, so i removed it and done what you suggested. Then when i try to search i get that error again which i posted a few posts before also.
This is only when the global code is in front of the ?>. With the action link it works fine but with out it, i get that error when i try to use the search bar.
By the way every thing is displaying ok, looks just how i want it. Just the search isn't actually working