SimplePortal
Customization => Custom Coding => Topic started by: willerby on February 07, 2011, 11:05:38 AM
-
As a forum grows, members tend to ask similar questions and create new topics for issues covered elsewhere. I couldn't find a Mod to remind members to search before posting a new topic or question but for a long while I had a simple BBC block that only appeared on the post screen in red letters...
Please remember to SEARCH the forum before starting a new topic or posting a question:
Today, I finally got round to adding the simpleportal Search block to the post screen and hacked around the code in PortalBlocks.php so that this is now a combination of my original message and a search input box... as follows:
(http://img193.imageshack.us/img193/4807/searchbeforeposting.jpg)
If you would like something like this to appear each time a member posts here is the code I used. I have no idea whether this is the correct way to do it but it works (expert coders please feel free to correct my crude attempts - it's how we all learn!)
global $scripturl, $txt, $context;
$block_parameters = array();
if ($return_parameters)
return $block_parameters;
echo '
<center><font size="2" color="red"><strong>Please remember to SEARCH the forum before starting a new topic or posting a question:</strong></font></center><br />
<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<div class="sp_center">
<input type="text" name="search" size="80" maxlength="80" value="" />
<input type="submit" name="submit" value="', $txt['search'], '" />
<input type="hidden" name="advanced" value="0" />
</div>
</form>';
Set up a PHP block with this code.
Tick Display Options>Advanced Options and then expand Select Actions
Tick Post
In Style Options select No Title
Make sure the block is active and has the relevant permissions (could be post group based just for newbies?) and check it by going to post a new topic or reply. You can play with css to alter the box options as you see fit. Entering errorbox in the Custom Body Class will result in a beautiful pink background and red border to make it stand out ;D
W
-
Very nice Willerby ;)
-
it also works in smf 1.1.12
Only the search button is not visible, too bad
great job
solution found smf 1.1.12
find
<input type="submit" name="submit" value="', $txt['search'], '" />
replace
<input type="submit" name="submit" value="search" />