PDA

View Full Version : str_replace Question That Seems REALLY Familiar


Digital Jedi
12-11-2013, 09:39 AM
It's 5:30 in the morning. I slept for about three hours in my daughter's bed making sure she stopped jumping up like a prairie dog and yelling at the night light. (Don't ask. It's something she does. On school nights.) So I'm not sure why my plugin isn't working.

parse_templates
$picturebitLink = '<a href=\"album.php?$session[sessionurl]albumid=$albuminfo[albumid]&amp;pictureid=$picture[pictureid]\">';
$hsLink = $vbulletin->templatecache['highslide_album_link'];
$vbulletin->templatecache['album_picturebit'] = str_replace($picturebitLink, $hsLink, $vbulletin->templatecache['album_picturebit']);

I have this dim recollection that I ran into this issue once before way back when Boofoo was still with us. I think Superman or BoP said it had to do with the ? but couldn't understand why. Anyone run into this issue before? I'm going to sleep. Wake me when you've wrote my plugin for me...zzzzzzzzzzzzzzzzzzzzzzzzzzzzz.....

ozzy47
12-11-2013, 11:03 AM
Perhaps try this:

$picturebitLink = '<a href="album.php?' . $session['sessionurl'] . 'albumid=$albuminfo[albumid]&amp;pictureid=$picture[pictureid]">';
$hsLink = $vbulletin->templatecache['highslide_album_link'];
$vbulletin->templatecache['album_picturebit'] = str_replace($picturebitLink, $hsLink, $vbulletin->templatecache['album_picturebit']);

Digital Jedi
12-11-2013, 05:17 PM
Thanks. This doesn't appear to work for me, either. I suppose I could replace the link a bit at a time, but that seems messy (not to mention gives me weird looking templates.) So I guess it isn't just conditionals and line breaks that are a problem with str_replace.

Thank you for bearing with my 5AM silliness.

ozzy47
12-11-2013, 08:13 PM
What is not working, the link, the replace, or all of it?

Digital Jedi
12-11-2013, 08:16 PM
It's not replacing the link. I am curious as to why that doesn't work, but I went ahead and replaced the link in a couple of parts, instead of all at once.

ozzy47
12-11-2013, 08:21 PM
Yeah that is curious, what hook were you using, so if I ever get board I can play around.

Digital Jedi
12-11-2013, 08:52 PM
<i>parse_templates</i>, which is working for other str_replace functions I have in the same plugin.