PDA

View Full Version : Find and Replace


TheInsaneManiac
12-18-2008, 05:32 PM
I recently formatted my computer and lost a bunch of my stuff. I haven't made any modifications in awhile and can't remember squat. I like to do my template edits with a script since I have like 4 styles. I can't remember the script so I was hoping someone could help me out maybe one of you guys have a better script than I had before. Any help would be appreciated.

Dismounted
12-19-2008, 02:57 AM
TMS (Template Modification System) by Kirby Andreas?

Or do you mean: [How-To] Plugins for Template Edits (Adv. Version) (https://vborg.vbsupport.ru/showthread.php?t=151332)

TheInsaneManiac
12-19-2008, 04:48 AM
The second one, thanks very much Dismounted.

EDIT: I just tried something really simple and it didn't work for me:
<hookname>global</hookname>
<phpcode><![CDATA[
$find = 'home_page';
$replace = 'removed';
$vbulletin->templatecache['memberinfo_block_contactinfo'] = str_replace($find, $replace . $find, $vbulletin->templatecache['memberinfo_block_contactinfo']);
]]></phpcode>

Dismounted
12-19-2008, 05:08 AM
"global" is not a hook. I suggest you do it via the Admin CP.

TheInsaneManiac
12-19-2008, 07:33 PM
"global" is not a hook. I suggest you do it via the Admin CP.
I know I replaced that in my script because I couldn't get memberinfo_start to work, but then I looked again and it was member_start haha. I'll give it a shot again thanks.

Edit:
If conditionals are giving me trouble. Here's the code I am using, but it keeps replacing it even if they aren't banned.

<plugin active="1" executionorder="1" product="vbulletin">
<title><![CDATA[Ban Home Page1]]></title>
<hookname>member_start</hookname>
<phpcode><![CDATA[
if ($vbulletin->options['banhome_enabled'])
{
$find = '<!-- Ban Home Begin -->';
$replace = '<if condition=\"is_member_of($userinfo, 8)\">Home Page Removed<else />';
$vbulletin->templatecache['memberinfo_block_contactinfo'] = str_replace($find, $replace . $find, $vbulletin->templatecache['memberinfo_block_contactinfo']);
}
]]></phpcode>
</plugin>
<plugin active="1" executionorder="2" product="vbulletin">
<title><![CDATA[Ban Home Page2]]></title>
<hookname>member_start</hookname>
<phpcode><![CDATA[
if ($vbulletin->options['banhome_enabled'])
{
$find = '<!-- Ban Home End -->';
$replace = '</if>';
$vbulletin->templatecache['memberinfo_block_contactinfo'] = str_replace($find, $replace . $find, $vbulletin->templatecache['memberinfo_block_contactinfo']);
}
]]></phpcode>
</plugin>

Dismounted
12-20-2008, 02:39 AM
The template is already parsed into raw PHP in the cache. You need to do the same. Or you could just put the conditional outside and save yourself some processing.
if ($vbulletin->options['banhome_enabled'] AND is_member_of($userinfo, 8))
{
$find = '<!-- Ban Home Begin -->';
$replace = 'Home Page Removed';
$vbulletin->templatecache['memberinfo_block_contactinfo'] = str_replace($find, $replace . $find, $vbulletin->templatecache['memberinfo_block_contactinfo']);
}

TheInsaneManiac
12-20-2008, 09:59 PM
is_member_of($userinfo, 8) doesn't work, that will only display the message if the member is banned and viewing their profile. I need the message to display on profiles that are banned.

I'm trying to make this as less of a template edit as possible since I have 4 styles. Is there anyway to include the conditional and let it work or no?

Lynne
12-20-2008, 10:41 PM
is_member_of($userinfo, 8) should work to display something if the user who's profile you are looking at is a member of usergroup 8. If that is your banned group, then the condition should be true if you are viewing a profile of a banned member.

TheInsaneManiac
12-21-2008, 01:07 AM
is_member_of($userinfo, 8) should work to display something if the user who's profile you are looking at is a member of usergroup 8. If that is your banned group, then the condition should be true if you are viewing a profile of a banned member.
I've tried it more than once and if I remove the extra conditional it will work fine, but when adding what Dismounted said, it no longer would work.

Dismounted
12-21-2008, 02:38 AM
Try $prepared instead of $userinfo.

TheInsaneManiac
12-21-2008, 07:25 AM
Nope :(

TheInsaneManiac
12-22-2008, 08:00 PM
Any other ideas?

Dismounted
12-23-2008, 02:12 AM
Which hook are you putting the plugin on? The hook may be too early. Try member_complete.

TheInsaneManiac
12-28-2008, 05:04 PM
Which hook are you putting the plugin on? The hook may be too early. Try member_complete.

Tried that too dude. No luck :( other ideas?

Dismounted
12-30-2008, 08:48 AM
What is the code you are using now and where are you hooking it at?

Andreas
12-30-2008, 05:43 PM
Tampering with the template cache is a really bad idea, epecially if you cache the template cache (sic!).

If I could, I'd bite myself into the ass for coming up with this idea some ages ago ...

TheInsaneManiac
12-30-2008, 05:55 PM
<plugins>
<plugin active="1" executionorder="1" product="vbulletin">
<title><![CDATA[Ban Home Page1]]></title>
<hookname>member_complete</hookname>
<phpcode><![CDATA[
if ($vbulletin->options['banhome_enabled'] AND is_member_of($prepared, 8))
{
$find = '<!-- Ban Home Begin -->';
$replace = 'Home Page Removed';
$vbulletin->templatecache['memberinfo_block_contactinfo'] = str_replace($find, $replace . $find, $vbulletin->templatecache['memberinfo_block_contactinfo']);
}
]]></phpcode>
</plugin>
</plugins>