Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PHP and HTML question


Guest

Recommended Posts

Posted

Howdy again,

 

Long story short, I have a website which is in two parts: the informational .html pages and the ecommerce shopping cart (php pages).

 

While setting up this cart, I learned php and css for the first time and now understand how useful they are.

 

However, my html pages have been created (not all of them, I do want to expand the site to MANY pages).

 

I am fine with how to deal with creating a css stylesheet for my html pages. No problems there.

 

But now I want to implement such things as creating a separate navigation file so I just update the one file when adding new pages to the site and not updating each page individually. Note, the navigation links on my html pages are different than those of my cart, so I will need to create a new file and not use the existing one from the cart. Are ya confused yet? LOL.

 

Now, from my limited understanding - the moment you add one snippet of php to a hmtl, you must change the page ext from .html to .php. Is this correct?

 

I also just read this evening in one of the threads here that if you change your pages from html to php, then you will have seo problems.

 

So, can I do a php-like function on a html without having to change the extension?

 

I tried the

<?php include('nav.html')?>

into my index.html page but it did not work. Is it because my page is still .html?

 

What other alternatives do I have? I do not know enough about php to actually create .php pages on my own. Granted, my html pages are basic html, nothing fancy at all.

 

I've tried reading php tutorials, but have yet to find one that answers questions about using php in html pages and such.

 

Any suggestions would be greatly appreciated. I want to get set up right with the 6 html pages I have right now so when I go to add more and more pages, I'm set up from the get-go. I am looking to have hundreds of pages within the year (not including the shopping cart pages!).

 

On another forum, I was given this answer with no further details - how correct is it and could someone explain it in more details.......

 

You can tell the PHP engine to parse HTML pages.

 

I think it's something like this added to your httpd.conf or .htaccess:-

 

AddHandler application/x-httpd-php .html

 

Basically, the only elements of my .html pages that I would need "called in" would be: navigation links (nav.html - my nav in my html pages are different then from the store's nav), a header and a footer (both of which are different from the header and footer in my store).

 

Thanks in advance for some help on this.

Posted

Any help purty peas? *grins*

 

I'm kind of at a stand-still on expanding my site until I know if and how I can do the above.

Posted

Well - what you were told is correct. You basically need to tell PHP which pages to parse. Any page with extension .php will be automatically recognised, but if you have access to the settings, then you can parse files with any extension as long as it's specified. Would depend though what your hosting company allows you to do. The advice above shows you how to tell the PHP module on your server to parse pages with .html extension.

 

As for SEO - yes, changing the extension is basically the same as creating a new page. But you could do 301 redirects - that way you'll keep the search engine ranking. If you do a search on 301 redirects you should find helpful info on how to write it. 301 is also good when you move/rename pages.

 

all the best, Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Posted

So, if I just add the line of code to my .htaccess file, and then add in the php code to include the appropriate file, then I won't have to do anything with 301's, right? I won't have "new" pages, because they will still be the .html pages.

 

If I can eliminate the nav links, header and footer html pieces from each pages, and replace with the php includes snippet, that will clean up my pages a bit more.

 

I've also been, in the process of this, creating a stylesheet for the html pages.

 

All this to clean up the code on the pages for faster loading times, and to be more seo spider/bot friendly - as per instructions of major seo and forum sites.

Posted

I'd just clarify with your hosting company though that you can amend the PHP file to also parse HTML before you go ahead.

 

PS: the file extension of the "include" files by the way doesn't matter, only the file extension of the main file. You could even make the include files something like ".inc" and it would still work.

 

Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Posted
I'd just clarify with your hosting company though that you can amend the PHP file to also parse HTML before you go ahead.

 

I'm sorry, I do not understand what you mean by this.

 

I have access to my .htaccess file - no problems there. Otherwise, why would I need to ask my hosting company about this issue?

 

What PHP file are you referring to?

 

I just want to be able to add a snippet of php code to my .html pages of my site, so I can use the php command to "draw in" (or whatever the correct phraseology is) a header, footer, and nav ... just like is done in osc. I won't be doing anything to any PHP file/page.

 

Sorry if I am not grasping something obvious here. Am just looking for detailed instructions.

Posted

I got it to work! woohoo!

 

Thank you for your advice and suggestion, Terra - I appreciate it!

Posted

Barbara - I actually meant to post that there is another way as well - just for completness sake (very glad you got it to work!): You could rewrite files with .php extension into .html URLs with modRewrite via your .htaccess file. It's the same principle used by Chemo's "Ultimate SEO URLs" in the contribs section (though his stuff is a lot more advanced).

 

How it works - you've got .php files. Then in your .htaccess file you tell Apache to output them as .html. When a customer views the page, they come up as .html. Just google for modRewrite and you should get info / help. The "bible" is here: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

 

NB: not a better solution, just another way to get things done.

 

all the best, Edith

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...