Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: njtweb on May 03, 2019, 08:00:51 AM

Title: Add Text To User Info Bit
Post by: njtweb on May 03, 2019, 08:00:51 AM
I know this spot isn't called user info bit, I just don't know what the technical name is for this area.

Per the attached image. I need to put "REGISTRATION NOT REQUIRED" in red before the "Guest/Member" detail area. I post all of my articles on social media and it's inevitable I will get at least one a-hole a day who will complain, "I can't read this article, it's making me register, this is spam". As you can see I already have it in a top block on my TinyPortal front page but that's not good enough. Guests see the login/register area as soon as they click a link on their phones. They won't go any further.

Can somebody advise which template file I need to edit, (presumably index) and where exactly in the code so I don't screw it up?

I just want to add the following HTML.

<font color="#ff0000>REGISTRATION NOT REQUIRED</font>

Thank you, any help is greatly appreciated.
Title: Re: Add Text To User Info Bit
Post by: Sir Osis of Liver on May 03, 2019, 01:06:58 PM
index.template.php



// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
elseif (!empty($context['show_login_bar']))
{
echo '
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
<form id="guest_form" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
<div class="info">
<span style="color: #ff0000;">REGISTRATION NOT REQUIRED</span><br />', sprintf($txt['welcome_guest'], $txt['guest_title']), '
</div>
<input type="text" name="user" size="10" class="input_text" />
<input type="password" name="passwrd" size="10" class="input_password" />
<select name="cookielength">
<option value="60">', $txt['one_hour'], '</option>
<option value="1440">', $txt['one_day'], '</option>
<option value="10080">', $txt['one_week'], '</option>
<option value="43200">', $txt['one_month'], '</option>
<option value="-1" selected="selected">', $txt['forever'], '</option>
</select>
<input type="submit" value="', $txt['login'], '" class="button_submit" /><br />
<div class="info">', $txt['quick_login_dec'], '</div>';


Title: Re: Add Text To User Info Bit
Post by: njtweb on May 03, 2019, 01:51:13 PM
Quote from: Sir Osis of Liver on May 03, 2019, 01:06:58 PM
index.template.php



// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
elseif (!empty($context['show_login_bar']))
{
echo '
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
<form id="guest_form" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
<div class="info">
<span style="color: #ff0000;">REGISTRATION NOT REQUIRED</span><br />', sprintf($txt['welcome_guest'], $txt['guest_title']), '
</div>
<input type="text" name="user" size="10" class="input_text" />
<input type="password" name="passwrd" size="10" class="input_password" />
<select name="cookielength">
<option value="60">', $txt['one_hour'], '</option>
<option value="1440">', $txt['one_day'], '</option>
<option value="10080">', $txt['one_week'], '</option>
<option value="43200">', $txt['one_month'], '</option>
<option value="-1" selected="selected">', $txt['forever'], '</option>
</select>
<input type="submit" value="', $txt['login'], '" class="button_submit" /><br />
<div class="info">', $txt['quick_login_dec'], '</div>';



If I could buy you a beer, I most certainly would. Than you sir, very much appreciated.
Title: Re: Add Text To User Info Bit
Post by: Sir Osis of Liver on May 03, 2019, 09:47:09 PM

   (https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.thekrashsite.com%2Fpics%2Fbeerfund.png&hash=e0693b2d87e09e6fc6d4262309f18019bc2edeb4) (http://www.thekrashsite.com/donate.htm)   ;)
Title: Re: Add Text To User Info Bit
Post by: njtweb on May 04, 2019, 07:52:50 AM
Quote from: Sir Osis of Liver on May 03, 2019, 09:47:09 PM

   (https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.thekrashsite.com%2Fpics%2Fbeerfund.png&hash=e0693b2d87e09e6fc6d4262309f18019bc2edeb4) (http://www.thekrashsite.com/donate.htm)   ;)

Cyber beer sent!

(https://image.shutterstock.com/image-vector/flat-isolated-vector-illustration-drinking-260nw-1065851969.jpg)
Title: Re: Add Text To User Info Bit
Post by: Mick. on May 04, 2019, 08:01:24 AM
No need to inject css styles directly to the page. Instead use a class and serve it from the css file. That's what is for.

Your theme's CSS file at the very end add,

.notrequired {
  color: #ff0000;
}


...and on the index.template just add...
<span class="notrequired">REGISTRATION NOT REQUIRED</span>
Title: Re: Add Text To User Info Bit
Post by: @rjen on May 04, 2019, 09:13:45 AM
Quote from: njtweb on May 03, 2019, 08:00:51 AM
I know this spot isn't called user info bit, I just don't know what the technical name is for this area.

Per the attached image. I need to put "REGISTRATION NOT REQUIRED" in red before the "Guest/Member" detail area. I post all of my articles on social media and it's inevitable I will get at least one a-hole a day who will complain, "I can't read this article, it's making me register, this is spam". As you can see I already have it in a top block on my TinyPortal front page but that's not good enough. Guests see the login/register area as soon as they click a link on their phones. They won't go any further.

Can somebody advise which template file I need to edit, (presumably index) and where exactly in the code so I don't screw it up?

I just want to add the following HTML.

<font color="#ff0000>REGISTRATION NOT REQUIRED</font>

Thank you, any help is greatly appreciated.

I know you have guest postings allowed and you are keeping your forum open and accessible to guests, so why do you even still show the Quick login area?
You do know that you can just suppress the complete Quick login block?
This way people can still register and login via the menu options, but your social media visitors will not be confronted with a login box at all.. seems the best way to deal with this...

Admin > Configuration > Features and Options > Layout
Show a quick login on every page > remove the tickbox...




Title: Re: Add Text To User Info Bit
Post by: njtweb on May 04, 2019, 10:23:22 AM
Quote from: @rjen on May 04, 2019, 09:13:45 AM
Quote from: njtweb on May 03, 2019, 08:00:51 AM
I know this spot isn't called user info bit, I just don't know what the technical name is for this area.

Per the attached image. I need to put "REGISTRATION NOT REQUIRED" in red before the "Guest/Member" detail area. I post all of my articles on social media and it's inevitable I will get at least one a-hole a day who will complain, "I can't read this article, it's making me register, this is spam". As you can see I already have it in a top block on my TinyPortal front page but that's not good enough. Guests see the login/register area as soon as they click a link on their phones. They won't go any further.

Can somebody advise which template file I need to edit, (presumably index) and where exactly in the code so I don't screw it up?

I just want to add the following HTML.

<font color="#ff0000>REGISTRATION NOT REQUIRED</font>

Thank you, any help is greatly appreciated.

I know you have guest postings allowed and you are keeping your forum open and accessible to guests, so why do you even still show the Quick login area?
You do know that you can just suppress the complete Quick login block?
This way people can still register and login via the menu options, but your social media visitors will not be confronted with a login box at all.. seems the best way to deal with this...

Admin > Configuration > Features and Options > Layout
Show a quick login on every page > remove the tickbox...

Did not know that. I learn something new every day. I'll see how that goes for a bit. Thanks rjen!
Title: Re: Add Text To User Info Bit
Post by: Sir Osis of Liver on May 04, 2019, 03:17:51 PM
Quote from: njtweb on May 04, 2019, 07:52:50 AM
Cyber beer sent!

(https://image.shutterstock.com/image-vector/flat-isolated-vector-illustration-drinking-260nw-1065851969.jpg)


          (https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.thekrashsite.com%2Fpics%2Fsnax.gif&hash=6dadc81102ed61594672f291fcfb940346ceaf79)