vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Find and Replace (https://vborg.vbsupport.ru/showthread.php?t=199187)

TheInsaneManiac 12-18-2008 05:32 PM

Find and Replace
 
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 [s]Kirby[/s] Andreas?

Or do you mean: [How-To] Plugins for Template Edits (Adv. Version)

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:
Code:

                <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

Quote:

Originally Posted by Dismounted (Post 1688510)
"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.

Code:

        <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.
PHP Code:

if ($vbulletin->options['banhome_enabled'] AND is_member_of($userinfo8))
{
    
$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

Quote:

Originally Posted by Lynne (Post 1689863)
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.


All times are GMT. The time now is 05:46 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01506 seconds
  • Memory Usage 1,746KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete