News:

Wondering if this will always be free?  See why free is better.

Main Menu

Private board uneeded code

Started by jrdeahl, October 01, 2008, 05:18:18 PM

Previous topic - Next topic

Deprecated

The false is part of an if statement:

if (condition) statement;

or

if (condition) statement;
else other_statement;

If "condition" is true the first statement is executed. If false the second (other_statement) is executed.

True is always true and false is always false, so if (false) means to never execute the statement.

It was just a quicker way to comment the code out, or the code could have been cut out. I like simple changes.

jrdeahl

What about the search on the right and the buttons on the left? The buttons are different if you are logged in. They should be on a different template shouldn't they?


Deprecated

What about the buttons? Rather than discussing which templates things are in, tell us what your problem is or what you want to do. And no, they are not different templates. They are the same template with buttons being visible depending on permissions.

To disable search for guests, go to Admin -> Members -> Permissions -> Permissions by Membergroup, find the Guests line and hit Modify. Find "Search for posts and topics" and remove the check mark, hit "Save changes."

I doubt there is easy any way to remove the Help or Registration tabs. (easy = without code changes)

jrdeahl

It is the same as it was to begin with. It is a private board and instead of having people getting confused or playing with all the buttons, etc, I want to get rid of the items in the red circle of the picture.

Once registered users, registered by the admin only, after the first time they log in they will bypass the login screen. At least that is what it is doing for me so far when I go to the forum.

John



Deprecated

So what more do you need to settle your problem?

jrdeahl

#25
How do I remove the items in the red circle in the picture below?

The else if (false) got rid of the  guest login items opposite the search, but not the search or the buttons below the search bar on the left.


jrdeahl

#26
I have tried to change the:

To disable search for guests, go to Admin -> Members -> Permissions -> Permissions by Membergroup, find the Guests line and hit Modify. Find "Search for posts and topics" and remove the check mark, hit "Save changes."

But it is already unchecked in my 1.1.6 and it still shows up. Maybe it disables it once a guest is in the board but since this is a private board guests don't get in to see. if that is true. More probably, it is just there but non functional.


John

[SiNaN]

If search area is the only problem;

index.template.php

Find:

echo '
<td class="titlebg2" align="right" nowrap="nowrap" valign="top">
<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">
<a href="', $scripturl, '?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" align="middle" style="margin: 0 1ex;" alt="" /></a>
<input type="text" name="search" value="" style="width: 190px;" />&nbsp;
<input type="submit" name="submit" value="', $txt[182], '" style="width: 11ex;" />
<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>
</td>


Replace:

if ($context['user']['is_logged'])
{
echo '
<td class="titlebg2" align="right" nowrap="nowrap" valign="top">
<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">
<a href="', $scripturl, '?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" align="middle" style="margin: 0 1ex;" alt="" /></a>
<input type="text" name="search" value="" style="width: 190px;" />&nbsp;
<input type="submit" name="submit" value="', $txt[182], '" style="width: 11ex;" />
<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>
</td>';
}
echo '


If you want to hide the buttons too.

Find:

template_menu();

Replace:

if ($context['user']['is_logged'])
template_menu();
Former SMF Core Developer | My Mods | SimplePortal

jrdeahl

Thank you, will try it tonight.

John

jrdeahl

#29
What version of smf are you working with? So far my code is different than every example shown me. I am on 1.1.6.

I did manage to get the if ($context['user']['is_logged']) at the bottom which hid the buttons on the bottom of the bar.

Problem is on the bottom part of first part I have different code. Php is so different from what I am used to I will have to download a manual and check it out. If anyone knows of a manual that shows things like </td>'; and their meaning I would be gratfull. And what is the end termination of an IF or ELSEIF.  Like if xyz <action>  endif. I can't seem to find a manual that shows those examples. 

Here is what I have.

// Show a random news item? (or you could pick one from news_lines...)
   if (!empty($settings['enable_news']))
      echo '
            <td width="90%" class="titlebg2">
               <span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>
            </td>';

>>>>>>>>>  if ($context['user']['is_logged'])

   echo '
            <td class="titlebg2" align="right" nowrap="nowrap" valign="top">
               <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">
                  <a href="', $scripturl, '?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" align="middle" style="margin: 0 1ex;" alt="" /></a>
                  <input type="text" name="search" value="" style="width: 190px;" />&nbsp;
                  <input type="submit" name="submit" value="', $txt[182], '" style="width: 11ex;" />
                  <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>
            
>>>>>>>>>>>>>>>>>
>>>>>>>>>  </td>';
>>>>>>>>>  }
>>>>>>>>>>>>>>>>>gives template parse error.


         </tr>
      </table>
   </div>';


   // Show the menu here, according to the menu sub template.
>>>>>>>>>  if ($context['user']['is_logged'])
   template_menu();


   // The main content should go here.
   echo '
   <div id="bodyarea" style="padding: 1ex 0px 2ex 0px;">';
}


I have gotten it down to this so far with mod 2 language php files. Just the search bar left.



jrdeahl

I think another way to get rid of the search would be to set the button to toggle the search area was defauted to off which would make it not show and then also take out the toggle button. Is it onclick and upshrink?

[SiNaN]

Check my codes again. I have a openning bracket after this:

if ($context['user']['is_logged'])

I see from your codes, you've missed it.
Former SMF Core Developer | My Mods | SimplePortal

jrdeahl

#32
I am still getting a "template parse error".



// Show a random news item? (or you could pick one from news_lines...)
   if (!empty($settings['enable_news']))
      echo '
            <td width="90%" class="titlebg2">
               <span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>
            </td>';
if ($context['user']['is_logged'])
{

   echo '
            <td class="titlebg2" align="right" nowrap="nowrap" valign="top">
               <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">
                  <a href="', $scripturl, '?action=search;advanced"><img src="'.$settings['images_url'].'/filter.gif" align="middle" style="margin: 0 1ex;" alt="" /></a>
                  <input type="text" name="search" value="" style="width: 190px;" />&nbsp;
                  <input type="submit" name="submit" value="', $txt[182], '" style="width: 11ex;" />
                  <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>
            </td>';
                  }
         
</tr>
      </table>
   </div>';


   // Show the menu here, according to the menu sub template.
if ($context['user']['is_logged'])   
template_menu();


   // The main content should go here.
   echo '
   <div id="bodyarea" style="padding: 1ex 0px 2ex 0px;">';
}

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

   echo '
   </div>';

Deprecated

Look at the middle colored part in your post:

   echo '
               </form>
            </td>';
                  }         
</tr>

That </tr> is what is causing your error. You need to add an echo statement:

   echo '
               </form>
            </td>';
                  }         
   echo '
</tr>

jrdeahl

ALL RIGHT!!!!!!! that did it.

Thanks a bunch!

I palyed with it today and couldn't get anywhere. I looked on the net for any kind of manual and could not find one that put the basics out there.

Combining html and php confuses it some.

I looked for meanings for <td>, <tr>, echo ' and others but can't find what they mean. The closest I came was </table> so I think <td> is table data. Echo is a replacement for print. But no echo '. Is the ' a null?

If anyone has a manual for the basics please let me know. I do have a lot of old programming experience so I know the structure, like beginning { and end } and if, else, endif. But if you do not know what they, like </tr>, mean it doesn't do a person much good. 


Thanks again.

John

PS - By the way, that also deactivated the toggle button.

Deprecated

You can find the meaning of any HTML tag by googling this: tag_name html tag

I recommend reading the W3Schools site preferentially because they have the very best explanations.


Combining HTML and PHP confuses it some? Hell no, it confuses it a lot!!! :)

echo is a PHP command that echoes whatever it is to the browser page.

For example, echo 'Hello world!'; would print "Hello world!" on the browser screen. Note the single quotes enclosing the message, and the semicolon which signals the end of the command.


Enjoy your forum! :)

jrdeahl

#36
so echo'; is sending nothing to the webpage?

Deprecated

No. The echo in the code I posted starts out echo '


and then everything on the following lines until another single quote ' and semicolon ; is sent. The echo is a multi-line command, or more accurately, white space (spaces, tabs, end of line) is not relevant and is ignored.

jrdeahl

I do not want to belabor this but are you saying:

echo '

text
text
text

echo';

displays all the text inbetween the two echos to the webpage?

Deprecated

Almost. I've corrected it below:

Quote from: jrdeahl on October 10, 2008, 08:59:14 PM

echo '

text
text
text

';

displays all the text inbetween the first echo ' to the last '; to the webpage

Please visit PHP.net for more information on how to write PHP. Also check out W3Schools.

Advertisement: