Post by jsampsonPC » Wed Aug 06, 2008 11:26 am

I've decided to start my hands at making a new template for a clients opencart installation, and I was curious why the PHP code in the template file looks like this:

Code: Select all

<?php if (isset($language)) { ?>
<?php echo $language; ?>
<?php } ?>
<?php if (isset($currency)) { ?>
<?php echo $currency; ?>
<?php } ?>
<?php if (isset($search)) { ?>
<?php echo $search; ?>
<?php } ?>
and not

Code: Select all

<?php
  if (isset($language)) {
    echo $language;
  }
  if (isset($currency)) {
    echo $currency;
  }
  if (isset($search)) {
    echo $search;
  } 
?>

Newbie

Posts

Joined
Sun Jul 27, 2008 2:09 am

Post by Luvz2drv » Wed Aug 06, 2008 4:01 pm

best answer i have is in case you wanted to move it around..

Global Moderator

Posts

Joined
Fri Mar 21, 2008 10:58 am

Post by jsampsonPC » Thu Aug 07, 2008 10:10 am

Luvz2drv wrote: best answer i have is in case you wanted to move it around..
Not sure I understand, but all is well :)

Newbie

Posts

Joined
Sun Jul 27, 2008 2:09 am

Post by fido-x » Thu Aug 07, 2008 7:41 pm

Each of these "modules" is an individual entity, it therefore makes logical sense to keep them as individual entities. And, as Luvz2drv stated, it makes them easier to move around. For example, you might decide you want your search block somewhere other than in the "bar", maybe you want it at the top of the side column. Keeping them separate, makes it easier to cut and paste.

Regards, Fido-X.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by Qphoria » Thu Aug 07, 2008 9:05 pm

Well, his point is still valid at the line level. You'd never move the if (isset($language)) { statement below the echo $currency; statement.

So something more like this would make sense:

Code: Select all

<?php if (isset($language)) { 
      echo $language;
} ?>

<?php if (isset($currency)) { ?>
      echo $currency;
} ?>

<?php if (isset($search)) { ?>
      echo $search; 
} ?>
But then it gets ugly and harder to follow the bracket lineup

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 1 guest