MyBB Community Forums

Full Version: Only show table to guests
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
How would I make it so the following table is shown to guests? This code will be in the header template.

<table border="0" cellspacing="1" cellpadding="4" class="tborder">
<tr>
<td class="thead"><strong>Welcome Guests!</strong></td>
</tr>
<tr>
<td class="trow1"><span class="smalltext">Disregard</span></td>
</tr>
</table>
<br />
The header set of templates has one called header_guests or something like that, using that will only display your code to guests.
by using template conditionals plugin ; <if $mybb->user['uid'] == 0 then>your code</if>
(2012-01-07, 08:40 AM)ranjani Wrote: [ -> ]by using template conditionals plugin ; <if $mybb->user['uid'] == 0 then>your code</if>

Very useful, but not needed in this case, if he's just going to use the header set of templates anyway.

There's a set for guests, and members.
^ no doubt, header_welcomeblock_guest template can be used ; that might require css adjustments !
Whenever I paste the OP code into header_welcomeblock_guest behind:
<script type="text/javascript">
<!--
	lang.username = "{$lang->login_username}";
	lang.password = "{$lang->login_password}";
	lang.login = "{$lang->login}";
	lang.lost_password = " &mdash; <a href=\"{$mybb->settings['bburl']}/member.php?action=lostpw\">{$lang->lost_password}<\/a>";
	lang.register_url = " &mdash; <a href=\"{$mybb->settings['bburl']}/member.php?action=register\">{$lang->welcome_register}<\/a>";
	lang.remember_me = "{$lang->remember_me}";
// -->
</script>

It doesn't show up at all.
Is there a plugin alternative that can show a this table for guests only? I went through a few mods but I can't seem to find this.
^ adding a table to myBB's default theme's template works fine - may be CSS adjustments are required for your theme ..
OR may be you can use a plugin like group notice
What do I need to change in the code to make the table display in "forumdisplay_threadlist"?

<?php
$plugins->add_hook('admin_user_groups_edit', 'gn');
$plugins->add_hook('admin_user_groups_edit_commit', 'gn_do');
$plugins->add_hook("index_start", "gn_notice");

function gn_info()
{
	return array(
		'name'			=> 'Group Notice',
		'description'	=> 'Allows you to set a notice displayed to certain groups.',
		'website'		=> 'http://www.coderzplanet.net',
		'author'		=> 'Jammerx2',
		'authorsite'	=> 'http://www.coderzplanet.net',
		'version'		=> '1.0',
		'guid'        => '7027f0d07a6a84e998eea8ef6b62bda3'
	);
}

function gn_activate()
{
global $mybb, $db;
	$db->query("ALTER TABLE `".TABLE_PREFIX."usergroups` ADD `gn` VARCHAR(1500) NOT NULL");


	$gn = array(
		"title" => "group_notice",
		"template" => "<style>
.gnotice {
    background: #D6ECA6;
    border-top: 2px solid #8DC93E;
    border-bottom: 2px solid #8DC93E;
    text-align: center;
    margin: 10px auto;
    padding: 5px 20px;
}
</style>
<p class=\"gnotice\"><b>{\$notice}</b></p>
<br>",
		"sid" => -1,
		"dateline" => TIME_NOW
	);
	
	$db->insert_query("templates", $gn);

	include MYBB_ROOT."/inc/adminfunctions_templates.php";
	
	find_replace_templatesets("index", "#".preg_quote("{\$header}")."#i", "{\$header}\r\n{\$gn}");
}

function gn_deactivate()
{
global $mybb, $db;
	$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP `gn`");

	include MYBB_ROOT."/inc/adminfunctions_templates.php";
	
	find_replace_templatesets("index", "#".preg_quote("\r\n{\$gn}")."#i", "", 0);

	$db->delete_query("templates", "title = 'group_notice'");

}

function gn()
{
global $plugins;
$plugins->add_hook("admin_formcontainer_output_row", "gn_row");
}

function gn_do()
{
global $db, $mybb, $usergroup;
	
	$update_array = array(
		"gn" => $db->escape_string($mybb->input['gn']),
	);

	$db->update_query("usergroups", $update_array, "gid='".intval($usergroup['gid'])."'");

}

function gn_row($pluginargs)
{
global $db, $mybb, $lang, $user, $form, $form_container, $usergroup;

if($pluginargs['title'] == "Miscellaneous")
{
		$gn = array(
			$form->generate_text_area('gn', $usergroup['gn'], array()),
			);
		$form_container->output_row("Group Notice", "Set a group notice that will be displayed to members of this group.", "<div class=\"group_settings_bit\">".implode("</div><div class=\"group_settings_bit\">", $gn)."</div>");
}
}

function gn_notice()
{
	global $db, $mybb, $templates, $gn, $notice;
	
	if($mybb->usergroup['gn'] != "")
	{
	$notice = $mybb->usergroup['gn'];	

	eval("\$gn = \"".$templates->get("group_notice")."\";");
	}
}
?>
^Try replacing that plugin with this:

<?php
$plugins->add_hook('admin_user_groups_edit', 'gn');
$plugins->add_hook('admin_user_groups_edit_commit', 'gn_do');
$plugins->add_hook("forumdisplay_thread", "gn_notice");

function gn_info()
{
    return array(
        'name'            => 'Group Notice',
        'description'    => 'Allows you to set a notice displayed to certain groups.',
        'website'        => 'http://www.coderzplanet.net',
        'author'        => 'Jammerx2',
        'authorsite'    => 'http://www.coderzplanet.net',
        'version'        => '1.0',
        'guid'        => '7027f0d07a6a84e998eea8ef6b62bda3'
    );
}

function gn_activate()
{
global $mybb, $db;
    $db->query("ALTER TABLE `".TABLE_PREFIX."usergroups` ADD `gn` VARCHAR(1500) NOT NULL");


    $gn = array(
        "title" => "group_notice",
        "template" => "<style>
.gnotice {
    background: #D6ECA6;
    border-top: 2px solid #8DC93E;
    border-bottom: 2px solid #8DC93E;
    text-align: center;
    margin: 10px auto;
    padding: 5px 20px;
}
</style>
<p class=\"gnotice\"><b>{\$notice}</b></p>
<br>",
        "sid" => -1,
        "dateline" => TIME_NOW
    );
    
    $db->insert_query("templates", $gn);

    include MYBB_ROOT."/inc/adminfunctions_templates.php";
    
    find_replace_templatesets("index", "#".preg_quote("{\$header}")."#i", "{\$header}\r\n{\$gn}");
}

function gn_deactivate()
{
global $mybb, $db;
    $db->query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP `gn`");

    include MYBB_ROOT."/inc/adminfunctions_templates.php";
    
    find_replace_templatesets("index", "#".preg_quote("\r\n{\$gn}")."#i", "", 0);

    $db->delete_query("templates", "title = 'group_notice'");

}

function gn()
{
global $plugins;
$plugins->add_hook("admin_formcontainer_output_row", "gn_row");
}

function gn_do()
{
global $db, $mybb, $usergroup;
    
    $update_array = array(
        "gn" => $db->escape_string($mybb->input['gn']),
    );

    $db->update_query("usergroups", $update_array, "gid='".intval($usergroup['gid'])."'");

}

function gn_row($pluginargs)
{
global $db, $mybb, $lang, $user, $form, $form_container, $usergroup;

if($pluginargs['title'] == "Miscellaneous")
{
        $gn = array(
            $form->generate_text_area('gn', $usergroup['gn'], array()),
            );
        $form_container->output_row("Group Notice", "Set a group notice that will be displayed to members of this group.", "<div class=\"group_settings_bit\">".implode("</div><div class=\"group_settings_bit\">", $gn)."</div>");
}
}

function gn_notice()
{
    global $db, $mybb, $templates, $gn, $notice;
    
    if($mybb->usergroup['gn'] != "")
    {
    $notice = $mybb->usergroup['gn'];    

    eval("\$gn = \"".$templates->get("group_notice")."\";");
    }
}
?>
That didn't change anything Sad I'm not even sure you changed anything. Could you try again please.
Pages: 1 2