View Full Version : Reuse HTML code
09-06-2009, 11:58 PM
Like many others I am also reusing HTML code on several pages.
What is most efficient way to do so?
09-07-2009, 01:41 AM
PHP's include if you have php set up.
09-07-2009, 03:00 PM
see my post here for a nice easy "includes" tutorial link: http://www.dynamicdrive.com/forums/showthread.php?p=202040#post202040
09-07-2009, 07:32 PM
On a bigger scale, and in some ways easier (harder to set up, but easier because you don't need to program much yourself), you can use CMS ("content management system") if you need a lot of pages with editable content and related layouts. That is the sort of system in place on most sites that have lots of similar looking pages with varied text. Basically you will use the system to set up your layout(s) (using templates) then use it to manage your content (text and other html that is put in the pages). The initial setup can be a bit of a pain, mostly just getting it to run smoothly on your server, but once that's done there's no code to mess with except the embedded html you want to output and it goes much faster than trying to do it manually. Google "CMS" to see your options. There are a lot and some are free-- one of the free ones should be fine, but there are some expensive solutions if you have the money.
In summary, there are three levels of complexity:
1. Basic site without much to manage: no need for any sort of content management.
2. Some similar elements across pages, not a huge site, but getting beyond what you want to do manually: use php, etc., to make some basic included elements and maybe even use a database a bit if it gets more complex.
3. Lots of pages, lots of changing content, and many people editing the site especially those who don't know the more complex coding languages very well: use a pre-built CMS solution.
And of course if you want to, you could always write your own CMS, but that takes a lot of time and is only worth it if you can't find a way to use a pre-built one. CMS setups aren't actually that hard to write (just slow), and they're built around the same ideas as a basic php, etc., based system you could write yourself, just with a lot more code.
09-08-2009, 11:07 PM
Many thanks to all.
09-10-2009, 12:06 PM
I set up a CMS using a combination of a few free scripts - here's the post with all the information: http://www.dynamicdrive.com/forums/showthread.php?t=47256
It may or may not suit your needs but its certainly a starting point.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.