Mobile app version of vmapp.org
Login or Join
Rambettina238

: 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) { ?>

@Rambettina238

Posted in: #Opencart #Php #Theme

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?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Rambettina238

2 Comments

Sorted by latest first Latest Oldest Best

 

@Samaraweera270

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;
}
}
?>

10% popularity Vote Up Vote Down


 

@Gail5422790

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme