View Full Version : Template Problem
ckgreenman
05-05-2010, 11:57 AM
Hello, I'm attempting to port a mod (someone else's) to VB4 and I'm having a problem with one of the templates.
The mod has a main templates and calls the other templates using variables. I modified the main template and the php file so that the variables are now registered and the sub templates are called using the {vb:raw } syntax. The problem is in one of the sub templates I need to pass variables to it as well but as soon as I try to specify a {vb: } type variable (even stylevars) it won't let me save the template. I get the following error:
Warning: Invalid argument supplied for foreach() in [path]/includes/functions.php on line 3332
and the following dialog:
https://vborg.vbsupport.ru/external/2010/05/57.png
Any any ideas where the problem might be?
Thanks.
EDIT: I checked and as far as I'm aware of there are no if statements in the template.
Lynne
05-05-2010, 01:25 PM
What is the code you are adding that seems to be causing the problem?
ckgreenman
05-05-2010, 03:07 PM
What is the code you are adding that seems to be causing the problem?
What triggers it is {vb: anything. I did a test adding {} then {vb} then {vb:} and the last one triggered it.
I found a work around though. There was some javascript in the template so I pulled all of it out and put it into a new template then called IT from the main template and now I can save the original template without error.
EDIT:
The problem is definitely in the javascript somewhere. The javascript is needing variables from the PHP file but when I try to reference the variable using {vb:raw variablename} i get the same error when I save the template.
I poked through the javascript and everything LOOKS ok but I'm no expert. Is there anything I should keep an eye out for?
Deceptor
05-05-2010, 03:44 PM
I had a similar error pop up not so long ago. Check that the "<vb:if condition>" tags are all written correctly, since that's what caused the same error when I was porting templates and had missed one.
In vB3 it's: <if condition="...."><else /></if>
In vB4 it's: <vb:if condition="...."><vb:else /></vb:if>
ckgreenman
05-05-2010, 04:17 PM
I had a similar error pop up not so long ago. Check that the "<vb:if condition>" tags are all written correctly, since that's what caused the same error when I was porting templates and had missed one.
In vB3 it's: <if condition="...."><else /></if>
In vB4 it's: <vb:if condition="...."><vb:else /></vb:if>
I'm not using HTML <if> statements though. The template in question consists entirely of javascript (with the addition of the <script></script> tags). How would that apply?
Deceptor
05-05-2010, 04:24 PM
You might wanna post the template here then (or the offending part) otherwise we can't help much.
ckgreenman
05-05-2010, 04:41 PM
Ok this is enough to generate the issue
<script type="text/javascript">
//<![CDATA[
window.onload=Load_Map
function get_icon(type) {
var color;
if ((typeof(type)=="undefined") || (type==null))
{
color = "red"
}
else {
color = type
}
var icon = new GIcon();
icon.image = "$bburl/images/googlemapme/mm_20_"+ color +".png";
icon.shadow = "$bburl/images/googlemapme/mm_20_shadow.png";
icon.iconSize = new GSize(12, 20);
icon.shadowSize = new GSize(22, 20);
icon.iconAnchor = new GLatLng(20, 2);
icon.infoWindowAnchor = new GLatLng(1, 5);
return icon;
}
//]] </script>
As written it saves fine but if I add a vb variable (for example {vb:raw map_type}) then it won't save.
Lynne
05-05-2010, 06:09 PM
put <vb:literal> and </vb:literal> around your javascript.
ckgreenman
05-06-2010, 12:51 PM
Lynne, That seems to have fixed it. Thanks a bunch. :D
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.