vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How do I get a plugin to work that contains quotes in the replace string? (https://vborg.vbsupport.ru/showthread.php?t=182063)

4x4 Mecca 06-10-2008 04:55 AM

How do I get a plugin to work that contains quotes in the replace string?
 
For example, say I have this:

Code:

$stuff="<a href="showthread.php">test</a>";
$lookfor='$thread[highlight]';
$replace='$stuff';
$vbulletin->templatecache['threadbit'] = str_replace($lookfor,  $replace, $vbulletin->templatecache['threadbit']);

I will get tons of error codes because the $stuff line has quotes in it. I want to do template replacements via plugins rather than changing each file, but this is killing me. Any pointers? Thanks.

MoT3rror 06-10-2008 06:14 AM

PHP Code:

$stuff '<a href="showthread.php">test</a>'

Just you won't be able to put variables in between or you can do this.
PHP Code:

$stuff "<a href=\"showthread.php\">test</a>"

Which will allow variables in the quotes.

4x4 Mecca 06-10-2008 03:58 PM

you rock, I'll go try that now.

--------------- Added [DATE]1213117994[/DATE] at [TIME]1213117994[/TIME] ---------------

This is my actual code, it still doesn't load.
Code:

$threadprefixstuff="<a href=\"showthread.php?$session[sessionurl]t=$thread[threadid]$thread[highlight]\" id=\"thread_title_$thread[realthreadid]\"<if condition=\"$show[gotonewpost]\"> style=\"font-weight:bold\"</if>>$thread[threadtitle]</a>
                        $thread[movedprefix]
                        $thread[typeprefix]
                        $thread[moderatedprefix]
                        $thread[prefix_rich]";
$threadprefixlookfor="
                        $thread[movedprefix]
                        $thread[typeprefix]
                        $thread[moderatedprefix]
                        $thread[prefix_rich]
                        <a href=\"showthread.php?$session[sessionurl]t=$thread[threadid]$thread[highlight]\" id=\"thread_title_$thread[realthreadid]\"<if condition=\"$show[gotonewpost]\"> style=\"font-weight:bold\"</if>>$thread[threadtitle]</a>";
$threadprefixreplace="$threadprefixstuff";
$vbulletin->templatecache[threadbit] = str_replace($threadprefixlookfor,  $threadprefixreplace, $vbulletin->templatecache[threadbit]);


Opserty 06-10-2008 04:18 PM

You need to use single quotes (instead of double quotes), to encapsulate your search and replace strings e.t.c. As single quotes do not parse variables.

Dismounted 06-11-2008 06:52 AM

You can use single quotes - you just need to concatenate.


All times are GMT. The time now is 02:21 AM.

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.01080 seconds
  • Memory Usage 1,723KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete