Customizing SMF > SMF Coding Discussion

Separate search box and news box

(1/1)

Rehclip:
Alright.  So for the most part I've been able to figure things out.  Move things, change styles, change colors, change sizes, etc.  This is becoming a two part issue, because two things I wanted to do... turns out are linked together in a way that I can't figure out.

I have a menu bar that stretches at the top of the page and is fixed.  I would like to move the search field to that, which I now understand in SMF 2.0.2 is linked to the SMF menu itself, and not just a theme thing.  Second, I'd like to move the news box to a new place that is easier to see.  Unfortunately, I'm finding that both are linked together.

I am able to remove the WHOLE section with no problems.  However, someone smarter than me may already understand that if I try to remove the search form feature and leave in the news, I get a parse error.  If I leave the search form and delete the news item, I get a parse error.  I basically want these two detached so that I can move them wherever I want them... Which may end up being a task in itself with the whole menu thing.

Here is what I have been looking at.


--- Code: ---<div class="news normaltext">
<form id="search_form" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<input type="text" name="search" value="" class="input_text" />&nbsp;
<input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
<input type="hidden" name="advanced" value="0" />';

// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />';
// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';

echo '</form>';

// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<h2>', $txt['news'], ': </h2>
<p>', $context['random_news_line'], '</p>';

echo '
</div>
--- End code ---

My last resort will probably end up being to deactivate the news box, and move the search where I want.  Then code in my news manually.  But I'd rather be able to use the moderation feature for the news, in oppose to editing the files each time.

Any help is appreciated.  Thanks in advance!

emanuele:
Hello Rehclip and welcome to sm.org!

What you posted is a piece of php code that handle the SMF header. Of course you cannot split it up without change it a bit.
Don't know how familiar you are with php, though the issue there could be that you are removing pieces of code belonging to an "echo" without closing it properly.
Example:

--- Code: ---echo '
    this is one line
    this is the second line';
if ($a = 0)
    echo '
    this is a third line';

echo '
    another line again
    and a last one';
--- End code ---
you see that each "echo" has a single quote just after it and one before any other php block. So, if you want to remove "this is the second line" you cannot do this:

--- Code: ---echo '
    this is one line

--- End code ---
this will result in a parser error.
You have to close the echo statement:

--- Code: ---echo '
    this is one line';

--- End code ---
see the single quote and the semicolon at the end of the line?
Same goes at the beginning, you cannot do something like:

--- Code: ---    this is the second line';
if ($a = 0)

--- End code ---
you have to restore the echo:

--- Code: ---echo '
    this is the second line';
if ($a = 0)

--- End code ---

Navigation

[0] Message Index

Go to full version