TinyPortal

Development => Support => Topic started by: ApplianceJunk on January 31, 2008, 03:23:52 PM

Title: Looking to customize a searchbox block
Post by: ApplianceJunk on January 31, 2008, 03:23:52 PM
Could someone post the code I would have to use to create a search box that would look like the searchbox you get now when you go to block manager and pick searchbox?

What I would like to do is take the code and create a new search block using a scriptbox in the block manager.

Thank you,
Title: Re: Looking to customize a searchbox block
Post by: JPDeni on January 31, 2008, 04:27:29 PM
The code is in the TPortalBlocks.template.php file, which is in your theme directory.
Title: Re: Looking to customize a searchbox block
Post by: ApplianceJunk on January 31, 2008, 05:25:33 PM
Thanks for the reply.

Ok, I took a look there and found this.

<?php
// TPortal searchblock
function TPortal_searchbox()
{
global $context, $settings, $options, $txt , $scripturl;

echo '
<form  accept-charset="'
, $context['character_set'], '" action="', $scripturl, '?action=search2" method="post" style="padding: 0; text-align: center; margin: 0; margin-bottom: 5px;">
<br /><input type="text" name="search" value="" style="width: 85%;" /><br />
<input type="submit" name="submit" value="'
, $txt[182], '" style="width: 90%; margin: 4px;" /><br /><span class="smalltext">
<a href="'
, $scripturl, '?action=search;advanced">', $txt['smf298'], '</a></span>
<input type="hidden" name="advanced" value="0" />
</form>'
;

}
?>


I copy and paste this into a phpbox and get this error mesage showing up in that box when I view the site.

Parse error: parse error, unexpected '<' in /home/content/a/p/p/appliancejunk/html/forums/Sources/Load.php(1753) : eval()'d code(35) : eval()'d code on line 1

Not as simple as I thought....

Title: Re: Looking to customize a searchbox block
Post by: Lesmond on January 31, 2008, 05:47:27 PM
did you take off the <?php and ?>
Title: Re: Looking to customize a searchbox block
Post by: ApplianceJunk on January 31, 2008, 06:00:17 PM
Yeah, I tried that first.

function TPortal_searchbox()
{
global $context, $settings, $options, $txt , $scripturl;

echo '
<form  accept-charset="', $context['character_set'], '" action="', $scripturl, '?action=search2" method="post" style="padding: 0; text-align: center; margin: 0; margin-bottom: 5px;">
<br /><input type="text" name="search" value="" style="width: 85%;" /><br />
<input type="submit" name="submit" value="', $txt[182], '" style="width: 90%; margin: 4px;" /><br /><span class="smalltext">
<a href="', $scripturl, '?action=search;advanced">', $txt['smf298'], '</a></span>
<input type="hidden" name="advanced" value="0" />
</form>';

}


and when I do it that way I get this error.


Fatal error: Cannot redeclare tportal_searchbox() (previously declared in /home/content/a/p/p/appliancejunk/html/forums/Sources/Load.php(1753) : eval()'d code:7) in /home/content/a/p/p/appliancejunk/html/forums/Sources/Load.php(1753) : eval()'d code(35) : eval()'d code on line 1
Title: Re: Looking to customize a searchbox block
Post by: Lesmond on January 31, 2008, 06:07:26 PM
Try this

{
global $context, $settings, $options, $txt , $scripturl;

echo '
<form  accept-charset="', $context['character_set'], '" action="', $scripturl, '?action=search2" method="post" style="padding: 0; text-align: center; margin: 0; margin-bottom: 5px;">
<br /><input type="text" name="search" value="" style="width: 85%;" /><br />
<input type="submit" name="submit" value="', $txt[182], '" style="width: 90%; margin: 4px;" /><br /><span class="smalltext">
<a href="', $scripturl, '?action=search;advanced">', $txt['smf298'], '</a></span>
<input type="hidden" name="advanced" value="0" />
</form>';

}
Title: Re: Looking to customize a searchbox block
Post by: ApplianceJunk on January 31, 2008, 06:27:33 PM
That works, :)

The only difference is that this was removed?

function TPortal_searchbox()

Thanks,
Title: Re: Looking to customize a searchbox block
Post by: Lesmond on January 31, 2008, 06:34:22 PM
yup thats what I thought was causing the error, but I am not coder but thought it was worth a shot ;)

glad it works

oh I use a php box
Title: Re: Looking to customize a searchbox block
Post by: ApplianceJunk on January 31, 2008, 06:40:19 PM
thanks again,
  :up:
Title: Re: Looking to customize a searchbox block
Post by: G6Cad on January 31, 2008, 06:44:12 PM
function TPortal_searchbox()

Should have been

function TPortal_searchbox();

Title: Re: Looking to customize a searchbox block
Post by: ApplianceJunk on January 31, 2008, 06:52:24 PM
Just tried it with the

function TPortal_searchbox();

and with the I get this error message.

Parse error: parse error, unexpected ';', expecting '{' in /home/content/a/p/p/appliancejunk/html/forums/Sources/Load.php(1753) : eval()'d code(35) : eval()'d code on line 1
Title: Re: Looking to customize a searchbox block
Post by: JPDeni on January 31, 2008, 07:36:49 PM
What you want is:


global $context, $settings, $options, $txt , $scripturl;

echo '
<form  accept-charset="', $context['character_set'], '" action="', $scripturl, '?action=search2" method="post" style="padding: 0; text-align: center; margin: 0; margin-bottom: 5px;">
<br /><input type="text" name="search" value="" style="width: 85%;" /><br />
<input type="submit" name="submit" value="', $txt[182], '" style="width: 90%; margin: 4px;" /><br /><span class="smalltext">
<a href="', $scripturl, '?action=search;advanced">', $txt['smf298'], '</a></span>
<input type="hidden" name="advanced" value="0" />
</form>';


Sorry. I should have posted this in the first place. I misunderstood your level of experience.