: OpenCart template $module code I am using Opencart 1.5.1 but have a theme made for 1.4.9. The following template code won't work with 1.5.1: <?php foreach ($modules as $module) { ?>
I am using Opencart 1.5.1 but have a theme made for 1.4.9.
The following template code won't work with 1.5.1:
<?php foreach ($modules as $module) { ?>
<?php echo $module; ?>
<?php } ?>
Undefined variable: modules.
Invalid argument supplied for foreach().
What do I replace it with to work in 1.5.1?
More posts by @Rambettina238
2 Comments
Sorted by latest first Latest Oldest Best
Found a post about this question on opencart forums ..
Migrate theme from 1.4.9 to 1.5.1 (Undefined variable)s
Regarding the previous code, try the following :
<?php
if(isset($modules)){
foreach ($modules as $module) {
echo $module;
}
}
?>
Is modules defined? Do you know if you have modules set to show where that code is in the template?
You can do this:
<?php
if($modules){
foreach ($modules as $module) {
echo $module;
}
}
?>
This way if $modules is not set to anything, it ignores the foreach loop.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.