vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   "Compiled template" (https://vborg.vbsupport.ru/showthread.php?t=275691)

Scanu 12-20-2011 03:19 PM

Well that's a little more difficult i'm thinking about this code
Code:

$forum['title'] = str_replace('"', "'", $forum['title']);
what would be the hook location?
*replace the " with the '

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

Ok this is driving me insane o.o! I can't put a ' in a string!!
Is vbulletin?! Why this code doesn't work? :(
Code:

$find = '<h2 class="forumtitle"><a href="\' . vB_Template_Runtime::linkBuild("forum", $forum) . \'">\' . $forum[\'title\'] . \'</a></h2>';
$replace = ' \' ';


$vbulletin->templatecache['forumhome_forumbit_level2_post'] = str_replace($find, $replace, $vbulletin->templatecache['forumhome_forumbit_level2_post']);

If i write " all is ok but if i write \' it delete all the template! This is impossible..

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

Ok i'm thinking that this template doesn't accepts apostrophe i tried this code and it works
Code:

$find = 'test';
$replace = <<<DH DH;
$vbulletin->templatecache['forumhome_forumbit_level2_post'] = str_replace($find, $replace, $vbulletin->templatecache['forumhome_forumbit_level2_post']);

Then i tried this code but doesn't works!
Code:

$find = 'test';
$replace = <<<DH ' DH;
$vbulletin->templatecache['forumhome_forumbit_level2_post'] = str_replace($find, $replace, $vbulletin->templatecache['forumhome_forumbit_level2_post']);

What i mean with "doesn't work" it delete the template

kh99 12-20-2011 08:44 PM

To be honest, I'm not sure what you're trying to do exactly. Are you tryig to delete the entire $find string? And why are you trying to replace it with a ' ?

Scanu 12-20-2011 08:57 PM

No these are test for see what's the problem, and the problem is that if i put a ' in the template, all the template is eliminated, so the problem is why i can't put a ' in a template!? Is a vbulletin problem

kh99 12-20-2011 09:02 PM

I think you need to figure out the right 2 levels of "escaping". Maybe try this:

Code:

$replace = "\\'";

Scanu 12-20-2011 09:06 PM

Nothing, i think that is a problem of vbulletin, because in php all it's right and works

kh99 12-20-2011 09:22 PM

But the template string is php code, and if you change it so that the quotes are mismatched the template will go away because when it's evaluated it will produce an error. So I think it's just that you're not ending up with valid php code.

Scanu 12-21-2011 08:21 AM

Yes this is possible but the question is why the this is not a valid php code!? I mean why this works
Code:

$find = 'test';
$replace = "  ";
$vbulletin->templatecache['forumhome_forumbit_level2_post'] = str_replace($find, $replace, $vbulletin->templatecache['forumhome_forumbit_level2_post']);

And this doesn't work
Code:

$find = 'test';
$replace = " ' ";
$vbulletin->templatecache['forumhome_forumbit_level2_post'] = str_replace($find, $replace, $vbulletin->templatecache['forumhome_forumbit_level2_post']);


kh99 12-21-2011 08:56 AM

I guess it depends where test is in the template, but you're adding one single quote, so wouldn't it mess up the quote matching?

Scanu 12-21-2011 09:18 AM

Test can be located wherever, what do you mean with "you're adding one single quote, so wouldn't it mess up the quote matching"
The string is declared by " and so i can write " ' "

kh99 12-21-2011 09:26 AM

The templatecache string uses single quotes, so unless you are careful where you put it, you're probably creating mismatched quotes.

ETA: unless you're saying that test that you're replacing is in a double-quoted string? That's why I asked where it was. Do you have a way to print out the templatecache string so you can see it? I think if you print it out before and after your replace, you'll probably be able to see what the problem is.


All times are GMT. The time now is 12:26 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.01675 seconds
  • Memory Usage 1,735KB
  • 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
  • (7)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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