Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Comment out unused code in template?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 05-03-2012, 06:43 AM
 
Mike SSI Mike SSI is offline
 

Advanced Member
  
Join Date: Feb 2011
Posts: 86
 

Default Comment out unused code in template?

Which is a better approach when customizing a template file?
A. Comment out {* *} unused code.
B. Remove unused code completely.

I've always commented out unused code for a couple reasons. First, I may want to reuse the code at a later date and second, I thought it causes less issues when patching and upgrading templates.

What does everyone else do?
__________________
X-Cart Gold 4.7.5
Reply With Quote
  #2  
Old 05-03-2012, 07:13 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Comment out unused code in template?

Its a good question, I can't say that I stick to one method or the other, it depends on the setup and situation.

If I am working in a custom skin directory (which I highly recommend you do), then I just remove the code. In this case /common_files has a backup so I don't need to worry about losing the original code. With the unnecessary code gone, the template reads much easier.

While I am working out a solution, I usually comment out pieces temporarily as I am determining their function and usefulness. After I'm finished I remove the commented out pieces.

Now If I am just making a quick fix or edit, and not creating a custom skin, I always simply comment out and make notes to my change.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following user thanks totaltec for this useful post:
Ksenia (03-17-2014)
  #3  
Old 05-03-2012, 07:34 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,191
 

Default Re: Comment out unused code in template?

Comment it out. While deleting it may look like a cleaner solution leaving the code in there commented out will not hurt and as you said - it is there if you need it later. Smarty completely ignores anything commented out and it does not show in the html code as well. And use smarty comments {* *} not html comments <!-- -> - html comments will show in final html code.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #4  
Old 03-16-2014, 11:10 AM
 
Steel Steel is offline
 

eXpert
  
Join Date: Dec 2006
Posts: 253
 

Default Re: Comment out unused code in template?

If a merchant never intends to utilize a module like the Bill Me Later Financing module, you suggest that commenting it out on the tpl file would be best practice. If the number of modules not being utilized was significant, would there be any benefit to removing the specifically related code from CSS and/or PHP files?
__________________
X-Cart Gold v4.6.6
Reply With Quote
  #5  
Old 03-16-2014, 04:48 PM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Comment out unused code in template?

A good practice is to NOT edit the code in common_files ever - instead apply the technique that Mike discusses in his video:

http://www.youtube.com/watch?v=5nkd7FPHMdA

I typically will comment the daylights out of my templates -- because you just may revisit something a few years from now and you will think, "WTF was the coder thinking?" -- but I can see in the comments that I was the freaking idiot that did this...

Where this technique becomes messy is if you are purchasing 3rd party mods -- and the 3rd party wants common_files template edits. SO you have to work around that.

The idea that "I'll leave the commented out code in-place just in case of a future upgrade" is a myth. If you're upgrading, you are starting from scratch with new core. Your edits may or may not be useful. But the idea that you can upgrade any template file that's been well modified or commented out is, well, fantasy. It doesn't really matter what you do to the templates.

NOW -- php files -- comment the daylights out of them too... but like templates, all the commenting in the world will not solve your upgrade challenge if you ever upgrade. But commented files are better than nothing.

Good luck!
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote

The following 3 users thank carpeperdiem for this useful post:
Ksenia (03-17-2014), qualiteam (03-19-2014), Steel (03-16-2014)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:02 AM.

   

 
X-Cart forums © 2001-2020