Post by lasa » Tue May 21, 2013 1:14 am

Hi,
I was wondering if there is a developers tool of some sort that can help show where an item is to prossibly modify it.
I'm thinking along the lines of Firebug, how it shows you exactly what affects what on your site.
Something that might show were the info is coming from... order.tpl line 159

I could really use something... I can make changes and document myself but 6 months from now who knows if I will remember..lol

Lasa

Active Member

Posts

Joined
Tue Apr 16, 2013 9:11 am

Post by WilliamBD » Thu May 23, 2013 10:59 pm

You can use code comments. Your comments should be enough for you to understand and it is always better to put more information than less information.

Documented code normally has a paragraph at the store of a file, before a method to explain it and any possibly confusing bit of code has explanations as well. In the documentation also every function has its inputs and outputs listed and any pre-requirements to the inputs and the format of the output. As you can see this is a lot of comments but one line of comments now could save you hours later trying to figure out what it does.

PHP are // or /* comment */ or
/*
Blah
Blah more
*/
HTML has <!-- comment here -->

Any code that I add to help a forum user I put // ADDED : START and // ADDED : END around.

*Disclaimer: I hope I have been as clear as possible and helpful. If you are unsure of anything please ask I will be happy to help - I do frequently watch the posts I have posted in previously.

How to change prices across a whole multi-store, with a baseline price for each product:
http://forum.opencart.com/viewtopic.php ... 24#p406793


Active Member

Posts

Joined
Fri Feb 08, 2013 9:33 pm

Post by Cleo » Thu May 23, 2013 11:26 pm

Thank you for posting this WilliamBD, I will keep that in my notes!

If there was some kind of "tag system" I would tag it as "useful"

Regards
Cleo

Opencart v1.5.4.1 fr/en
Theme: Custom
vqmod-2.6.0


User avatar
Active Member

Posts

Joined
Wed Mar 09, 2011 5:19 am

Post by lasa » Fri May 24, 2013 2:06 am

Thanks William all good stuff!
Lasa

Active Member

Posts

Joined
Tue Apr 16, 2013 9:11 am

Post by jgsw » Fri May 24, 2013 4:45 am

Interesting topic Lasa,

In addition to WilliamBD's post I find a useful way for commenting in HTML (if file is run as php, such as .tpl files in opencart):

Code: Select all

<html><?php // Comment here wont be visible when I view source in a browser ?>

Quick Edit Admin Panel (40% off!) - CSS Unique (only $10!)
Sticky Admin Menu (Free) - Add Scripts & Styles to head (Free)


Active Member

Posts

Joined
Sat Mar 16, 2013 3:13 am

Post by WilliamBD » Fri May 24, 2013 5:08 am

Quick note - any comments done in php will not be shown in the code on the client side.
<!-- Comment in html --> will show in the source code of a webpage.
<?php // Comment in php ?> will not show in the source of a webpage.

Which is better? Given the comments show how the code works, html I would choose. If you are trying to decode some template then you may like to put some html comments in to see where you are in the code working. This also allows all the php in a template to not get covered in comments that may make the php harder to understand. But if neither of these things are an issue then the php comments are just as good as html comments.

People do complain that opencart has few comments but with the comments gone it is easier to see the code beneath it. I have worked with projects that for every one line of php there are four or five lines of comments with it. It created a smoke that made the underlying code whilst told a very good clear story was hidden in a sea of comments.

*Disclaimer: I hope I have been as clear as possible and helpful. If you are unsure of anything please ask I will be happy to help - I do frequently watch the posts I have posted in previously.

How to change prices across a whole multi-store, with a baseline price for each product:
http://forum.opencart.com/viewtopic.php ... 24#p406793


Active Member

Posts

Joined
Fri Feb 08, 2013 9:33 pm

Post by rph » Fri May 24, 2013 5:42 am

Familiarizing yourself with MVC architecture will help immensely. You can find a mini primer in relation to OpenCart at:

http://forum.opencart.com/viewtopic.php?f=29&t=2544

You can find which controller you're working with from the route in the URL.

http://store.com/index.php?route=product/product&product_id=40

Would be:

/catalog/controller/product/product.php

http://store.com/admin/index.php?route=extension/shipping&token=f0bd321r30aba6f4c2a270f71a24fb05

Would be:

/admin/controller/extension/shipping.php

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by Johnathan » Fri May 24, 2013 6:51 am

Expanding on what rph said, once you know the controller then you can look inside for the model files it loads, which would be located in:

/catalog/model/
or
/admin/model/

You can also tell which template file it passes variables to, which is often the same filepath as the controller, but in the "view" side of things:

/catalog/view/theme/default/template/
or
/admin/view/template/

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by Cleo » Fri May 24, 2013 9:31 am

Lots of good information in this thread especially for noob like me :)

Thank you Lasa for starting it and thank you to everyone who replied and shared their knowledge!

Regards

Cleo

Opencart v1.5.4.1 fr/en
Theme: Custom
vqmod-2.6.0


User avatar
Active Member

Posts

Joined
Wed Mar 09, 2011 5:19 am

Post by lasa » Fri May 24, 2013 7:16 pm

This is great! this exactly what I need...thanks to everybody.
lasa

Active Member

Posts

Joined
Tue Apr 16, 2013 9:11 am

Post by rph » Sat May 25, 2013 6:58 am

It also looks like Jay put together a very comprehensive guide on Stackoverflow:

http://stackoverflow.com/questions/1347 ... ncart-guru

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by lasa » Sun May 26, 2013 9:29 am

Ryan definitely a great link for people that understand code and want to take OC to the next level... for us code-ly "challenged" that link was down right scary! I'm definitely not there... yet! :)

Lasa

Active Member

Posts

Joined
Tue Apr 16, 2013 9:11 am
Who is online

Users browsing this forum: No registered users and 35 guests