PDA

View Full Version : Search and str_replace


Seven Skins
12-02-2009, 06:25 PM
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
12-02-2009, 06:37 PM
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
12-02-2009, 06:38 PM
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
12-02-2009, 06:45 PM
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
12-02-2009, 06:51 PM
Put it in the ad_footer_start template.

Seven Skins
12-02-2009, 06:52 PM
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
12-02-2009, 07:00 PM
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
12-02-2009, 07:17 PM
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
12-02-2009, 07:22 PM
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
12-02-2009, 07:26 PM
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
12-02-2009, 07:38 PM
I wouldn't know how to get it any closer to the top then that with out a manual edit.

Seven Skins
12-02-2009, 07:56 PM
I guess manual edit or str_replace the 3rd line will have to do.

Thanks for helping out.

BBR-APBT
12-02-2009, 07:58 PM
Your welcome