Jump to content



Latest News: (loading..)

PHP Coding


  • Please log in to reply
22 replies to this topic

#1   mongoled

mongoled
  • Members
  • 61 posts
  • Real Name:Andrew

Posted 04 December 2010 - 12:01 PM

Hi,

If I wanted to add the following statement

if ( DO_SOMETHING > 0) 
echo ''; 
else { OUTPUT_SOMETHING }

to the file catalog/includes/modules/boxes/bm_whats_new line 49

How would I do this?

Whatever I try I keep getting the following error message

Parse error: syntax error, unexpected T_IF in

What I am trying to do is add code, in so that I can turn off the prices

Ive been trying stuff like this

if ( SHOW_ACCOUNT > 0) echo ''; else {echo ' . $whats_new_price . '); }

Hope someone can assist.......

#2   Mark Evans

Mark Evans

    Code Monkey Rockstar

  • Core Team
  • 2,518 posts
  • Real Name:Mark
  • Gender:Male
  • Location:Behind you :-P

Posted 04 December 2010 - 12:10 PM

http://uk.php.net/manual/en/control-structures.else.php ?
Mark Evans
osCommerce Monkey & Lead Guitarist for "Sparky + the Monkeys" (Album on sale in all good record shops)

---------------------------------------
Software is like sex: It's better when it's free. (Linus Torvalds)

#3 ONLINE   burt

burt

    Code Monkey

  • Community Team
  • 7,871 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 04 December 2010 - 12:23 PM

echo (DO_SOMETHING > 0) ? '' : OUTPUT_SOMETHING;

OR

if (DO_SOMETHING > 0) {
   echo '';
}
else {
   echo OUTPUT_SOMETHING;
}

OR

if (DO_SOMETHING <= 0) echo OUTPUT_SOMETHING;

I would use the first one.

You need to make sure that "DO_SOMETHING" is comparable against the number zero.  You need to make sure that "OUTPUT_SOMETHING" is something that can be output.
Dummies guide to designing osCommerce 2.3 Click Me

Or maybe a ready made theme for your shop ??

Warning: My posts may contain Horsemeat.

#4   FWR Media

FWR Media
  • Community Sponsor
  • 6,839 posts
  • Real Name:Robert Fisher
  • Gender:Male
  • Location:Stowmarket - Suffolk - UK

Posted 04 December 2010 - 01:00 PM

Personally I would avoid using the ternary operator ( truth_expr ? expr1 : expr2 ),  it is great for one liners but leads to confusing code.

Also The following alternative control structure was missed which is ideal for embedding PHP into HTML

<div id="some_id">
<?php if ( $something == $something_else ): ?>
  <div>$something is equal to $something_else</div>
<?php elseif ( $something != $something_else ): ?>
  <div>$something is NOT equal to $something_else</div>
<?php endif; ?> 
</div>

Edited by FWR Media, 04 December 2010 - 01:02 PM.


#5   mongoled

mongoled
  • Members
  • 61 posts
  • Real Name:Andrew

Posted 09 December 2010 - 01:18 PM

Hello, thanks for your quick responses!

Ive tried the suggestions, but still the same error.

Maybe it cant be done in the context I am trying.

Here is the code

$data = '<div class="ui-widget infoBoxContainer">' .
'  <div class="ui-widget-header infoBoxHeading"><a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '">' . MODULE_BOXES_WHATS_NEW_BOX_TITLE . '</a></div>' .
'  <div class="ui-widget-content infoBoxContents" style="text-align: center;"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . '</a><br />
				
' . $whats_new_price . '
				
</div>' .
'</div>';
I want to replace
' . $whats_new_price . '

With the construct we have discussed, but it is not working.

i.e. OUTPUT_SOMETHING == $whats_new_price

$data = '<div class="ui-widget infoBoxContainer">' .
'  <div class="ui-widget-header infoBoxHeading"><a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '">' . MODULE_BOXES_WHATS_NEW_BOX_TITLE . '</a></div>' .
'  <div class="ui-widget-content infoBoxContents" style="text-align: center;"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . '</a><br />
				
' . if (SHOW_ACCOUNT > 0) {echo '';}
else {echo $whats_new_price} . '
				
</div>' .
'</div>';

Error: Parse error: syntax error, unexpected T_IF

Could someone explain why?

Thanks

Edited by mongoled, 09 December 2010 - 01:25 PM.


#6 ONLINE   burt

burt

    Code Monkey

  • Community Team
  • 7,871 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 09 December 2010 - 02:01 PM

$data = '<div class="ui-widget infoBoxContainer">' .
		'  <div class="ui-widget-header infoBoxHeading"><a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '">' . MODULE_BOXES_WHATS_NEW_BOX_TITLE . '</a></div>' .
		'  <div class="ui-widget-content infoBoxContents" style="text-align: center;"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO,			'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . '</a><br />';
					
$data .= (SHOW_ACCOUNT > 0) ? '' : $whats_new_price;

$data .= '  </div>' . 
		 '</div>';

Please visit www.w3schools.com and find the PHP tutorial - this is basic knowledge which you need to read up on as it will help you in the future.

In Roberts example;

<div id="some_id">
<?php if ( $something == $something_else ): ?>
  <div>$something is equal to $something_else</div>
<?php elseif ( $something != $something_else ): ?>
  <div>$something is NOT equal to $something_else</div>
<?php endif; ?> 
</div>

I believe it is easier to read as so;

<div id="some_id">
  <div>
	<?php echo ($this == $that) ? 'this is equal to that' : 'this is different to that'; ?>
  </div>
</div>


Rob and I will agree to disagree :D
Dummies guide to designing osCommerce 2.3 Click Me

Or maybe a ready made theme for your shop ??

Warning: My posts may contain Horsemeat.

#7   mongoled

mongoled
  • Members
  • 61 posts
  • Real Name:Andrew

Posted 09 December 2010 - 02:07 PM

View Postburt, on 09 December 2010 - 02:01 PM, said:

$data = '<div class="ui-widget infoBoxContainer">' .
		'  <div class="ui-widget-header infoBoxHeading"><a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '">' . MODULE_BOXES_WHATS_NEW_BOX_TITLE . '</a></div>' .
		'  <div class="ui-widget-content infoBoxContents" style="text-align: center;"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO,			'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . '</a><br />';
					
$data .= (SHOW_ACCOUNT > 0) ? '' : $whats_new_price;

$data .= '  </div>' . 
		 '</div>';

Please visit www.w3schools.com and find the PHP tutorial - this is basic knowledge which you need to read up on as it will help you in the future.

In Roberts example;

<div id="some_id">
<?php if ( $something == $something_else ): ?>
  <div>$something is equal to $something_else</div>
<?php elseif ( $something != $something_else ): ?>
  <div>$something is NOT equal to $something_else</div>
<?php endif; ?> 
</div>

I believe it is easier to read as so;

<div id="some_id">
  <div>
	<?php echo ($this == $that) ? 'this is equal to that' : 'this is different to that'; ?>
  </div>
</div>


Rob and I will agree to disagree :D
Hello, thanks for the advice, but I am not aiming to learn PHP from the beginning, just have became stuck at this point, once I have resolved this then I can continue the development work!

I just want to know if what I am trying to do can be done in this example.

The problem I am experiencing here, is trying to make heads and tails with what the dots do! I havnt yet formualated in my head the logic behind when to use these or not.

But irrespective of that, is it too much to expect a experienced PHP coder to chime in and say to me, 'look you cannot do what you are trying to do in this context'?

I have spent already several hours looking at working example code, and trying to apply the logic to the problem I am facing, but so far with no success, and this was before I posted here!

So it would be really, really appreciated, that someone would be so kind, to assist me with this particular issue.....

#8 ONLINE   burt

burt

    Code Monkey

  • Community Team
  • 7,871 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 09 December 2010 - 02:25 PM

"I just want to know if what I am trying to do can be done in this example."

You did not even read my reply then.  I'll stop helping you now, sorry I wasted my time ;)
Dummies guide to designing osCommerce 2.3 Click Me

Or maybe a ready made theme for your shop ??

Warning: My posts may contain Horsemeat.

#9   mongoled

mongoled
  • Members
  • 61 posts
  • Real Name:Andrew

Posted 09 December 2010 - 02:36 PM

View Postburt, on 09 December 2010 - 02:25 PM, said:

"I just want to know if what I am trying to do can be done in this example."

You did not even read my reply then.  I'll stop helping you now, sorry I wasted my time ;)
Huh?

How did you come to that conclusion?

What gave you the idea that you are wasting your time?

I started by saying, thanks to your post, just because I said that I wouldnt read the w3schools.com PHP tutorial, you took that as my not having read your response?

Thats great logic!

Look, if you dont want to help me by assisting with the problem in hand, then thats fine, but it would be appreciated if you didnt turn my request for assistance on its head, by making me out to be ignorant.

That isnt very nice, do you know that?

Can you not appreciate that some of us have to allocate our time in an efficient manner as possible, Ive been through the w3schools.com PHP tutorials on numerous occasions in the past, and it has never ever helped me resolve a problem.

I some times wonder why I request help in forums, as most of the time its like trying to get blood out of a stone.

Sorry that I have 'wasted your time'

I asked for help, and instead Ive been made to feel like I have done something wrong, cheers........

Edited by mongoled, 09 December 2010 - 02:37 PM.


#10 ONLINE   burt

burt

    Code Monkey

  • Community Team
  • 7,871 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 09 December 2010 - 02:41 PM

I posted the code you needed, then you said "I some times wonder why I request help in forums, as most of the time its like trying to get blood out of a stone".  Gee, thanks a lot.

Well, I posted the corrected code.  READ it, then go to www.w3schools.com if you do not understand it.

I'm out.

Edited by burt, 09 December 2010 - 02:42 PM.

Dummies guide to designing osCommerce 2.3 Click Me

Or maybe a ready made theme for your shop ??

Warning: My posts may contain Horsemeat.

#11   mongoled

mongoled
  • Members
  • 61 posts
  • Real Name:Andrew

Posted 09 December 2010 - 02:51 PM

View Postburt, on 09 December 2010 - 02:41 PM, said:

I posted the code you needed, then you said "I some times wonder why I request help in forums, as most of the time its like trying to get blood out of a stone"  

Well, I posted the corrected code.  READ it, then go to www.w3schools.com if you do not understand it.

I'm out.
This is nothing to do with understanding your code.

Its the fact that what I am trying to do cannot be done, where I am trying to do it.

Ive think I have noticed where my logic is wrong, the code I want to apply and where I am trying to apply it to is not possible.

Thats what I think and will have an answer very soon.

And if I am correct, then well, what am I to say..........

Just for your information (not that you would care, judgeing from how you have responded to me) I am proficient in several programming languages, PHP has never been something I have used extensively.

But if I chose to assist someone with a problem, I would do that knowing that I would do my utmost to help them through, not leave them hanging by a thread just because they choose to question the manner of the assitance I was providing. I do my best to leave my EGO, behind the keyboard and NOT on the screen.

Sometimes I fail, but I do my best to learn..............

#12   mongoled

mongoled
  • Members
  • 61 posts
  • Real Name:Andrew

Posted 09 December 2010 - 02:58 PM

For the record, fixed the problem, again by myself.

As explained above, was putting the code in the wrong place.

Of course, someone proficient in PHP could have told me that!

If they had took the time to actually understand my problem.........

I will continue on my way, assisting people who I can assist, and trying to become a better person along the way.

Sorry for wasting your time.............

#13 ONLINE   burt

burt

    Code Monkey

  • Community Team
  • 7,871 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 09 December 2010 - 03:33 PM

View Postburt, on 09 December 2010 - 02:01 PM, said:

$data = '<div class="ui-widget infoBoxContainer">' .
		'  <div class="ui-widget-header infoBoxHeading"><a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '">' . MODULE_BOXES_WHATS_NEW_BOX_TITLE . '</a></div>' .
		'  <div class="ui-widget-content infoBoxContents" style="text-align: center;"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO,			'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . '</a><br />';
					
$data .= (SHOW_ACCOUNT > 0) ? '' : $whats_new_price;

$data .= '  </div>' . 
		 '</div>';

So this code did not work for you?
Dummies guide to designing osCommerce 2.3 Click Me

Or maybe a ready made theme for your shop ??

Warning: My posts may contain Horsemeat.

#14   mongoled

mongoled
  • Members
  • 61 posts
  • Real Name:Andrew

Posted 09 December 2010 - 04:54 PM

View Postburt, on 09 December 2010 - 03:33 PM, said:

So this code did not work for you?
Hello, firstly I would like to apologies for the manner of my posting

I want to be clear, Burt you have been very helpful, and my frustration got the better of me.

I hope you will allow me to give a brief explanation why.

I am not one who like things to be given on a plate.

In the context of the this thread, my thought process was, you could say stuck, on IF / ELSEIF statements, as this is something I have a prior understanding.

Now......

this

$data = '<div class="ui-widget infoBoxContainer">' .
' <div class="ui-widget-header infoBoxHeading"><a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '">' . MODULE_BOXES_WHATS_NEW_BOX_TITLE . '</a></div>' .
' <div class="ui-widget-content infoBoxContents" style="text-align: center;"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO,			'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . '</a><br />';
$data .= (SHOW_ACCOUNT > 0) ? '' : $whats_new_price;
$data .= '  </div>' . 
'</div>';

Threw me, as you no longer referenced any IF statements, and I failed to understand what had been done. This is my fault and I am sorry. I was frustrated as you didnt explain why you got rid of the IF statements, as I said previously, am not just looking for the answer, but to the reasons, so I can learn.

Now, my solution was by adding the IF statement before the data string.

i.e.

// Mod_Started //
if ( SHOW_ACCOUNT > 0) echo ''; 
elseif ( SHOW_PRICES > 0) echo ''; 
else
// Mod_Finished //
if (tep_not_null($random_product['specials_new_products_price']))
{
		  $whats_new_price = '<del>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</del><br />';
		  $whats_new_price .= '<span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>';
		} else { 
		  $whats_new_price = $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id']));
		}

		$data = '<div class="ui-widget infoBoxContainer">' .
				'  <div class="ui-widget-header infoBoxHeading"><a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '">' . MODULE_BOXES_WHATS_NEW_BOX_TITLE . '</a></div>' .
				'  <div class="ui-widget-content infoBoxContents" style="text-align: center;"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . '</a><br />
				
				' . $whats_new_price . '
				
				</div>' .
				'</div>'; 

I have tried your code, will get it to function correctly as a learning procedure, using it no longer gives me a parsing error, but havnt yet got it to do what I want it to do. Once I have understood the construct I can apply this.

Hope my apology is accepted, sorry for the overdrawn post........

Edited by mongoled, 09 December 2010 - 04:55 PM.


#15 ONLINE   burt

burt

    Code Monkey

  • Community Team
  • 7,871 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 09 December 2010 - 05:18 PM

No apology needed, I am sorry if I came across the wrong way, I have a habit of being "short on words" aka "blunt".

In my first post in this thread, I showed a couple more options instead of using "if else".  One of them is the ternary which is a shorthand system of "if / else".

So.  

echo (this == that) ? 'this equals that' : 'this is different than that';

is EXACTLY the same effect as

if (this == that) {
   echo 'this equals that';
}
else {
   echo 'this is different than that';
}

Do you see now?  With the latest code you posted, that won't really work, but you did not give enough detail beforehand for anyone to know exactly what you were/are trying to achieve.  It looks like you don't want to show prices based on SHOW_PRICES being 0 or not 0.  What is SHOW_ACCOUNT for?

Edited by burt, 09 December 2010 - 05:19 PM.

Dummies guide to designing osCommerce 2.3 Click Me

Or maybe a ready made theme for your shop ??

Warning: My posts may contain Horsemeat.

#16   FWR Media

FWR Media
  • Community Sponsor
  • 6,839 posts
  • Real Name:Robert Fisher
  • Gender:Male
  • Location:Stowmarket - Suffolk - UK

Posted 09 December 2010 - 08:18 PM

Burt is of course entirely correct.

And if you are simply outputting a variable the ternary may be fine, if  however you are looking to output html based on the result the following would be better for properly indented easy to understand html code: -

<div id="something">
<?php if ( SHOW_ACCOUNT > 0 ): ?>
  <div id="another_something">Was larger than 0</div>
<?php else: ?>
  <div id="another_something">Was NOT larger than 0</div>
<?php endif; ?>
</div>

A better example of the use of the alternative syntax when embedding PHP within html is a loop: -

<div id="results_div">
<?php foreach ( $big_array as $key => $value ): ?>
  <div id="single_result"><?php echo $value ?></div>
<?php endforeach; ?>
</div>

Produces neat html and is easy for html monkeys to understand as there are no brackets ( brackets also create big issues when those less knowledgeable try to add contributions ).

Edited by FWR Media, 09 December 2010 - 08:21 PM.


#17   geoffreywalton

geoffreywalton

    Contact me for Support

  • Community Sponsor
  • 8,055 posts
  • Real Name:Geoffrey Walton
  • Gender:Male
  • Location:Norfolk, UK (close to the centre of the universe)

Posted 09 December 2010 - 10:48 PM

Loved reading this thread :-)

Personally I much prefer brackets, as to me it is so much clearer.

Using a loop means you have to understand php, which is often not the case here.

Have I just made a comment about my php skills with those last 2 statements?

Anyway, now I'll just duck.

Cheers

G
Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

Virus Threat Scanner
My Contributions
Basic install answers.
Click here for Contributions / Add Ons.
UK your site.
Site Move.
Basic design info.

For links mentioned in old answers that are no longer here follow this link Useful Threads.

If this post was useful, click the Like This button over there ======>>>>>.

#18 ONLINE   burt

burt

    Code Monkey

  • Community Team
  • 7,871 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 09 December 2010 - 10:55 PM

The problem (or, if you look at it like I do, "the freedom) with PHP is that there is so many different ways to do something.

<div id="something">
  <div id="another_something"><?php echo ( SHOW_ACCOUNT > 0 ) ? 'Was larger than 0' : 'Was NOT larger than 0'; ?></div>
</div>

<div id="results_div">
  <?php foreach ( $big_array as $key => $value ) echo '  <div id="single_result">' . $value . '</div>';
</div>

"Loved reading this thread :-)"

I agree, good thread.  Fun.
Dummies guide to designing osCommerce 2.3 Click Me

Or maybe a ready made theme for your shop ??

Warning: My posts may contain Horsemeat.

#19   FWR Media

FWR Media
  • Community Sponsor
  • 6,839 posts
  • Real Name:Robert Fisher
  • Gender:Male
  • Location:Stowmarket - Suffolk - UK

Posted 09 December 2010 - 11:14 PM

If you take ..

<div id="something">
<?php if ( SHOW_ACCOUNT > 0 ): ?>
  <div id="another_something">Was larger than 0</div>
<?php else: ?>
  <div id="another_something">Was NOT larger than 0</div>
<?php endif; ?>
</div>

Then compare it to ( which is very similar to the code you encounter in osC mods )

<div id="something">
<?php 
  if ( SHOW_ACCOUNT > 0 ) {
?>
  <div id="another_something">Was larger than 0</div>
<?php 
  } else {
?>
  <div id="another_something">Was NOT larger than 0</div>
<?php
  }
?>
</div>

Viewing this from an html perspective the second ( in my opinion ) is complex for a person not versed in PHP.

Taking Burts ( I closed the line for you mate :) ) ..

<div id="results_div">
  <?php foreach ( $big_array as $key => $value ) echo '  <div id="single_result">' . $value . '</div>' ?>
</div>

Yes it is a shorter line but is it more readable than ..

<div id="results_div">
<?php foreach ( $big_array as $key => $value ): ?>
  <div id="single_result"><?php echo $value ?></div>
<?php endforeach; ?>
</div>

More to the point the html ( only ) coder can write as he's used to and just add in the PHP without disturbing his code .. his form and indentation ( not that anyone cares except me <it seems> )

#20 ONLINE   burt

burt

    Code Monkey

  • Community Team
  • 7,871 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 09 December 2010 - 11:33 PM

I agree with you Rob.  The usual osCommerce way is, I think, more confusing than your preferred way which is, I think, more confusing than the way I'd do it :D I think.  Well sometimes I do ;)

For indentation, that's another subject entirely!  I like to indent 4 spaces, thus;

<?php
if ($abc) {
	$something;
}
?>

Example, as I would write that differently anyway, but you get the drift.

Though in html, I like to use 2 spaces;

<body>
  <div id="this">
	<p>blah</p>
	<p>blugh</p> 
  </div>
</body>

What I really HATE seeing is this type;

<?php
if ($abc) 
{
[TAB]$something;
}
?>

Wasn't sure how to get a tabbed indentation in the forum?

I'm sure that someone has come up with some sort of indentation standard.  Is there one?
Dummies guide to designing osCommerce 2.3 Click Me

Or maybe a ready made theme for your shop ??

Warning: My posts may contain Horsemeat.