Mind blowing SEO improving and Google rank increasing Signature Rotator SEO Tool.

Thread: 

MyBB Board Messages Without Plugins - Guest Message - Conditional Message

Ads
banner
banner
banner
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#1
Support Team
MyBB is the best open source forum software however even the best forums can't have it all so here I will help you to create guest messages or welcome messages that will be visible only to unregistered users or guests. Also I will show you how to create board messages that will be visible across the whole forum for for guests only or for logged in users without any plugins!

I assume that you have mybb "conditional template" installed if don't download mybb conditional template.

First lets create mybb guest message that will only be visible to guests and only on index page.

Go to your admin CP-->Templates & Style-->Templates-->Your Template-->Index Page Templates-->index.

Inside the index template search for "{$header}" then add this code after "{$header}"

PHP Code:
<div style="padding: 1em; margin-bottom: 1em; padding: 1em; border: 1px solid #cc3344; border-radius: 5px; color: #000; background-color: #ffe4e9; margin-bottom: 1em;"><h3 style="padding: 0; margin: 0;">Welcome Guest</h3><p style="margin: 1em 0 0 0;">Add some description here</p></div

The message will look like this:
MyBB Board Messages Without Plugins   Guest Message   Conditional Message

This code will show be visible to all users, to make it show only to guests we need to use mybb conditional template.
PHP Code:
<if $mybb->user['uid'] <= '0' then></if> 

Now the final code to use is this:
PHP Code:
<if $mybb->user['uid'] <= '0' then>
<
div style="padding: 1em; margin-bottom: 1em; padding: 1em; border: 1px solid #cc3344; border-radius: 5px; color: #000; background-color: #ffe4e9; margin-bottom: 1em;"><h3 style="padding: 0; margin: 0;">Welcome Guest</h3><p style="margin: 1em 0 0 0;">Add some description here</p></div>
</if> 

Now to show this message across the whole forum board to guests only!
Go to your admin CP-->Templates & Style-->Templates-->Your Template-->Header Templates-->header.
Inside header template search for "<navigation>" and add this code above it!
PHP Code:
<if $mybb->user['uid'] <= '0' then>
<
div style="padding: 1em; margin-bottom: 1em; padding: 1em; border: 1px solid #cc3344; border-radius: 5px; color: #000; background-color: #ffe4e9; margin-bottom: 1em;"><h3 style="padding: 0; margin: 0;">Welcome Guest</h3><p style="margin: 1em 0 0 0;">Add some description here</p></div>
</if> 

All these messages are only visible to the guests, however if you want to show these messages to registered users only, then use this code for the same templates!

PHP Code:
<if $mybb->user['uid'then>
<
div style="padding: 1em; margin-bottom: 1em; padding: 1em; border: 1px solid #cc3344; border-radius: 5px;color: #000; background-color: #ffe4e9; margin-bottom: 1em;"><h3 style="padding: 0; margin: 0;">Welcome Guest</h3><p style="margin: 1em 0 0 0;">Add some description here</p></div>
</if> 

To hide whatever you want from guests use this code:
PHP Code:
<if $mybb->user['uid'then>
YOUR CODE HERE
                     
</if> 

To show whatever you want only to guests use this code:
PHP Code:
<if $mybb->user['uid'] <= '0' then>
YOUR CODE HERE
                     
</if> 

This version is for all of you that don't like to use DIV style and would rather use DIV class.

PHP Code:
<div class="board_messages"><h3 style="padding: 0; margin: 0;">Welcome Guest</h3><p style="margin: 1em 0 0 0;">Add some description here</p></div

Add this CSS code to your global.css file!

PHP Code:
.board_messages {
    
background-color#FFE4E9;
    
border1px solid #CC3344;
    
border-radius5px;
    
color#000000;
    
margin-bottom1em;
    
padding1em;



This is called "mybb conditional template" which allows you to do amazing things it just one of those things you have to have!
Thanks
destroyer Offline referral

Posts: 430
Joined: Jul 2013
Reputation: 3

#2
Senior Member
Thanks Marcus for this tutorial I don't really like using plugins so this one is perfect for me, one question how do I get this board message to show under the HOME ?
maya Offline referral

Posts: 1,058
Joined: May 2013
Reputation: 34

#3
Posting Freak
In stead of header add it to index template!
victor Offline referral

Posts: 638
Joined: Jun 2013
Reputation: 33

#4
Senior Member
Look great Marcus but I think you should also add border-radius: 5px; just to make border radius a bit more curved!
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#5
Support Team
Thanks Victor I have just updated the code Smile
ivan Offline referral

Posts: 713
Joined: Jul 2013
Reputation: 6

#6
Senior Member
So this Board Messages code only works with MyBB or it can be used in sites others than MyBB?
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#7
Support Team
This code is not limited to MyBB forum script it can be added to any website, this is only HTML and CSS code no PHP!
victor Offline referral

Posts: 638
Joined: Jun 2013
Reputation: 33

#8
Senior Member
It's better to use div class instead of style you should also add this option to your post!
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#9
Support Team
Thanks for the advice I will definitely add class option to my post!
letsplay Offline referral

Posts: 274
Joined: Jul 2013
Reputation: 1

#10
Senior Member
Why is CSS class is better than HTML style?
invisibe_dude Offline referral

Posts: 820
Joined: May 2013
Reputation: 24

#11
Posting Freak
First because by using "CSS CLASS" or "CSS ID" you have better control over your HTML style, also it reduces the amount of HTML code in your webpage too much HTML code will result in higher load time more errors and Google doesn't really like it so it can have a negative affect on your SEO!!!!!!!!
victor Offline referral

Posts: 638
Joined: Jun 2013
Reputation: 33

#12
Senior Member
Yeah excessive HTML code ain't good for SEO, try to use as little HTML style as possible if you care about SEO!
surenot Offline referral

Posts: 500
Joined: Jan 2014
Reputation: 16

#13
Senior Member
Don't wary about using css style directly in your HTML code just make sure the web page size is under 100kb that's what matters Smile
seo123 Offline referral

Posts: 427
Joined: Mar 2014
Reputation: 16

#14
Senior Member
You should always use either css class or css id
Evanto Offline referral

Posts: 14
Joined: Jan 2014
Reputation: 1

#15
Junior Member
MyBB template condition is one of the best plugins i have seem





User(s) browsing this thread: 1 Guest(s)