PDA

View Full Version : Search and str_replace


Seven Skins
02 Dec 2009, 19:25
I was just wondring can {vb:raw navbits.breadcrumb} be search and replace by using the code below?

$find = "{vb:raw navbits.breadcrumb}";
$replace = "Joe Blogs";
$myvar = str_replace($find,$replace,$myvar);

I have been trying to do this but no luck. I can search and replace normal HTML or Text.

Thanks

.

BBR-APBT
02 Dec 2009, 19:37
Is this in a plugin?

Try this code I got from one of Lynne's mods.

$find = '{vb:raw navbits.breadcrumb}';
$replace = "Joe Blogs". PHP_EOL;
$output = str_replace($find,$replace.$find, $output);

Lynne
02 Dec 2009, 19:38
No. You need to do search and replace on something that is 'real', not some variable that needs to be parsed.

edit: ". PHP_EOL" just gives a line break in the source code - php End Of Line.

Seven Skins
02 Dec 2009, 19:45
OK ... Is there any way I can add "{vb:raw my_text}" to the very top of footer template ... as the 1st line in footer template is "{vb:raw ad_location.ad_footer_start}".

.

BBR-APBT
02 Dec 2009, 19:51
Put it in the ad_footer_start template.

Seven Skins
02 Dec 2009, 19:52
Is this in a plugin?

Try this code I got from one of Lynne's mods.

$find = '{vb:raw navbits.breadcrumb}';
$replace = "Joe Blogs". PHP_EOL;
$output = str_replace($find,$replace.$find, $output);


I have tried this but does not work .... as Lynne said we need some thing real.
Yes it is a plugin.
I need to add "{vb:raw my_text}" on top of my footer template via plugin.

--------------- Added 1259787239 at 1259787239 ---------------

Put it in the ad_footer_start template.

"{vb:raw my_text}" has another template in it so this is not going to work.

BBR-APBT
02 Dec 2009, 20:00
Ok re-ordered to place it just below
{vb:raw ad_location.ad_footer_start}
{vb:raw ad_location.global_above_footer}
and above
<div class="footercontainer">

This should do the trick.

$find = '<div class="footercontainer">';
$replace = "{vb:raw my_text}". PHP_EOL;
$output = str_replace($find,$replace.$find, $output);

Seven Skins
02 Dec 2009, 20:17
I am making a product to release here and I want the users to just install and use ... no template modifications if possible.

If the template modification is needed I will just ask them to add "{vb:raw my_text}" on top of the footer template. It saves me writing plugins loads of plugins.

Thanks for your help.

.

BBR-APBT
02 Dec 2009, 20:22
I am making a product to release here and I want the users to just install and use ... no template modifications if possible.

If the template modification is needed I will just ask them to add "{vb:raw my_text}" on top of the footer template. It saves me writing plugins loads of plugins.

Thanks for your help.

.

So did this work?

$find = '<div class="footercontainer">';
$replace = "{vb:raw my_text}". PHP_EOL;
$output = str_replace($find,$replace.$find, $output);


people help me I help others.

Seven Skins
02 Dec 2009, 20:26
Yes it works I did try this before but thats the 3rd line in footer template. When you put ads in ad_location templates .. it screws the layout specially if the ads are wide.

.

BBR-APBT
02 Dec 2009, 20:38
I wouldn't know how to get it any closer to the top then that with out a manual edit.

Seven Skins
02 Dec 2009, 20:56
I guess manual edit or str_replace the 3rd line will have to do.

Thanks for helping out.

BBR-APBT
02 Dec 2009, 20:58
Your welcome