wikichris Posted April 23, 2009 Posted April 23, 2009 Hi, Just inherited a set of OScommerce sites. Never worked on the platform before. Most of it makes sense and I have been able to fix and do things for my new employer however I am confused with how seems to work on a low level. It could be that I am looking at a heavily modified install of OScommerce but my hunch is I am not. Let's take a script, index.php All seems familiar to me as I have worked on other CMSs...HTML, includes, PHP...I edit part of the content and save and it shows etc...BUT... When viewing index.php on a browser although the text content appears the HTML source seems like something fundementaly different. Indeed, content appears when added in some places but not in others. Something seems to be parsing and modifying the output of the .php pages when viewed on a browser because content appears correctly when after a certain tag (a <table> tag usually) but not before. If I use the shell and view the output of "php index.php" then I get the exact content expected but not in the browser. Same with product_info.php Thanks for your help - Chris
masat Posted April 23, 2009 Posted April 23, 2009 Hi Chris, Index.php is one of the more complex output pages in the application. There are several parts to the index page and while I won't go over each one you should see how the code works. I have heavily modified the shop I am currently work but you will see the following code in index.php on your installation... if ($category_depth == 'nested') { include(DIR_WS_SHOP . 'default_nested.php'); } elseif ($category_depth == 'products' || isset($_GET['manufacturers_id'])) { include(DIR_WS_SHOP . 'default_products.php'); } else { include(DIR_WS_SHOP . 'default_page.php'); } } This is the code between the body tags and I have removed the code between the if brackets and moved them to external files. I do this because I find the code easier to work with. Now, depending on what you are doing on the page is determined by the status of $category_depth which is assigned value in application_top.php. $category_depth can have various "Modes" determined by if you are viewing products or categories or neither. This is probably why you do not see what you expect to see from viewing the coding. You can say that index.php is a multifunctional page which can in deed make it confusing. For testing and learning purposes you can place a echo $category_depth somewhere towards the bottom of the page. This will tell you what mode the page is in and thereby know which section of code the script is using. I hope this helps you out a little. How do you know when you know what you want to do for the rest of your life?
spooks Posted April 23, 2009 Posted April 23, 2009 you php script is parsed by the server to produce the generated html source for the browser, the browser will never see any 'php' unless you have errors. PHP Tuition http://us.php.net/tut.php Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al.
wikichris Posted April 23, 2009 Author Posted April 23, 2009 you php script is parsed by the server to produce the generated html source for the browser, the browser will never see any 'php' unless you have errors. PHP Tuition http://us.php.net/tut.php I know about PHP (I am a developer) but this is an entirely different problem. Something else is parsing it. I have proved it. I am now trying to work out if this is OScommerce or something a previous developer has done. This is code embedded within my index.php No PHP anywhere. Just pure HTML. <td width="100%" valign="top"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td> Hello Graham! ...if I change it to this... <td width="100%" valign="top"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td> Hello David! I see the change. But there's something special about the <table> tag because if I do this... <td width="100%" valign="top">TEST <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td> Hello Graham! Then "TEST" appears NOWHERE in the HTML source of the page. I repeat, I get a different output when running index.php from the shell than through the browser and viewing the source. Completely different...except for the central content of the page. This is nothing to do with me not understanding what PHP does. Any ideas?
♥FWR Media Posted April 23, 2009 Posted April 23, 2009 Perhaps STS is installed Chris. I've never used Simple Template System but it does manipulate the code using replace routines and placeholders to offer an easy to template (albeit dog slow) osCommerce. Oh and there's another called BTS. Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
MrPhil Posted April 24, 2009 Posted April 24, 2009 Make sure all PHP code is surrounded by <?php and ?>, not <? and ?>. I've heard of <? firing up other processors than PHP on some systems. As I recall, there are some lazy programmer's short open tags <? in osC. It's worth a try.
♥FWR Media Posted April 24, 2009 Posted April 24, 2009 Make sure all PHP code is surrounded by <?php and ?>, not <? and ?>. I've heard of <? firing up other processors than PHP on some systems. As I recall, there are some lazy programmer's short open tags <? in osC. It's worth a try. Short open tags should not be used for mainly three reasons .. Firstly XML uses that tag <?xml and should be reserved as such. Secondly portability - short_open_tag is off by default in PHP distribution so using such code is not portable. Thirdly debugging - errors caused by php code not being parsed due to short tags can be a real pain to find. There are no short tags in the osCommerce distribution by the way .. the same cannot be said for many contributions. Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
wikichris Posted April 24, 2009 Author Posted April 24, 2009 Perhaps STS is installed Chris. I've never used Simple Template System but it does manipulate the code using replace routines and placeholders to offer an easy to template (albeit dog slow) osCommerce. Oh and there's another called BTS. BINGO! Thanks. This must be it.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.