Forum Moderators: coopster
2nd step (where i am stuck) is to insert a javascript call in the <head> section of the template.
For example, if the $html var contains this:
<html>
<head>
<title>My Blog</title>
</head>
<body>
hi 123
</body>
</html>
After modifying the var, it should end up like this:
<html>
<head>
<title>My Blog</title>
<javascript type="text/javascript" src="http://123123.com/blog/3941"></script>
</head>
<body>
hi 123
</body>
</html>
Thats all i need to get thinks done... my idea was to search "</head>" through regular expressions and then replace that with:
<javascript type="text/javascript" src="http://123123.com/blog/3941"></script>
</head>
So, i have two questions:
1) how can i achieve that?
2) is there another (better) way?
Thanks!
andres
[edited by: asantos at 11:05 pm (utc) on Dec. 23, 2006]
$html = '<html>
<head>
<title>My Blog</title>
<javascript type="text/javascript" src="http://123123.com/blog/'.$blogid.'"></script>
</head>
<body>
hi 123
</body>
</html>';
}
$template = str_replace('</head>','<script src="http://example.com/b/3213"></script>'."\n".'</head>',$template);
But i still need a way to check if the javascript call is already present in the template.
[edited by: jatar_k at 5:43 am (utc) on Dec. 24, 2006]
[edit reason] examplified [/edit]