problem with removing welcomeblock
ELY_M Offline
Junior Member
**
Posts: 1
Joined: Feb 2012
Post: #1
problem with removing welcomeblock
I am trying many regex and other ways to remove welcomeblock

I really hate mybb's find_replace_templatesets


PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/**
 * Mod Name: Remove Welcome Block links
 */


$plugins->add_hook("global_start", "removewelcome_header");
//$plugins->add_hook("global_end", "removewelcome_header");
//$plugins->add_hook("post_output_page", "removewelcome_header");


// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

function removewelcome_info()
{
	return array(
		"name"				=> "Remove Welcome Block",
		"description"		=> "Remove Welcome Block",
		"website"			=> "",
		"author"			=> "ELY M.",
		"authorsite"		=> "",
		"version"			=> "1.0.3",
		"guid" => "",
		"compatibility" => "*"
		);
}

function removewelcome_activate()
{
}


function removewelcome_deactivate()
{
}


/*

		<template name="header" version="1600"><![CDATA[	<div id="container">
		<a name="top" id="top"></a>
		<div id="header">
			<div class="logo"><a href="{$mybb->settings['bburl']}/index.php"><img src="{$theme['logo']}" alt="{$mybb->settings['bbname']}" title="{$mybb->settings['bbname']}" /></a></div>
			<div class="menu">
				<ul>
					<li><a href="{$mybb->settings['bburl']}/search.php"><img src="{$theme['imgdir']}/toplinks/search.gif" alt="" title="" />{$lang->toplinks_search}</a></li>
					<li><a href="{$mybb->settings['bburl']}/memberlist.php"><img src="{$theme['imgdir']}/toplinks/memberlist.gif" alt="" title="" />{$lang->toplinks_memberlist}</a></li>
					<li><a href="{$mybb->settings['bburl']}/calendar.php"><img src="{$theme['imgdir']}/toplinks/calendar.gif" alt="" title="" />{$lang->toplinks_calendar}</a></li>
					<li><a href="{$mybb->settings['bburl']}/misc.php?action=help"><img src="{$theme['imgdir']}/toplinks/help.gif" alt="" title="" />{$lang->toplinks_help}</a></li>
				</ul>
			</div>
			<hr class="hidden" />
			<div id="panel">
				{$welcomeblock}
			</div>
		</div>
		<hr class="hidden" />
		<br class="clear" />
		<div id="content">
			{$pm_notice}
			{$bannedwarning}
			{$bbclosedwarning}
			{$unreadreports}
			{$pending_joinrequests}
			<navigation>
			<br />
]]></template>

*/

function removewelcome_header()
{

global $mybb, $cache, $lang, $welcomeblock, $templates;


echo "TESTHEADER4";



    $template = &$GLOBALS['templates']->cache['header'];
    $template = strtr($template, array(
    // two copies of this replacement for MyBB 1.4 (uses Windows newlines) and 1.6 (Nix newlines)
    '				{$welcomeblock}'."\r" => '<!-- stupid welcomeblock was here -->'."\r",
    '				{$welcomeblock}'."\n" => '<!-- stupid welcomeblock was here -->'."\n",
    //"\t\t\t\t".'{$welcomeblock}'."\n" => 'TESTING....'."\n",
    '       {$welcomeblock}'."\n" => 'testing....'."\n",
    
        ));
        




//$templates->cache['header'] = preg_replace('#(.*?){$welcomeblock}(.*?)#si', 'TEST', $templates->cache['header']);


        

//if(!$templates->cache['header']) $templates->cache('header');
//$templates->cache['header'] = str_replace('				{$welcomeblock}', 'testing2222222', $templates->cache['header']);


//if(!$templates->cache['header']) $templates->cache('header');
//$templates->cache['header'] = preg_replace("~welcomeblock~", "testing...", $templates->cache['header']);

//$welcomeblock = "FUCK!!!";



}





?>

03-05-2012 03:15 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: problem with removing welcomeblock
Because the template cache isn't loaded when the global_start hook is fired.
Try modifying the $header global variable on global_end

My Blog
03-05-2012 04:54 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: