-
Reuse HTML code
Hi,
Like many others I am also reusing HTML code on several pages.
What is most efficient way to do so?
Thanks,
-
-
-
The Following User Says Thank You to bluewalrus For This Useful Post:
-
see my post here for a nice easy "includes" tutorial link: http://www.dynamicdrive.com/forums/s...040#post202040
-
The Following User Says Thank You to Beverleyh For This Useful Post:
-
The answers above are fine. Generally you will need to use another programming language (Javascript, PHP, etc.) to filter/copy/alter your html code then output it. If you are doing a template-style webpage, as is likely, then you will be best using PHP or another server-side scripting language; in fact that's what that type of language is designed for (in addition to using databases and other nice features). Javascript can work to a limited degree (mostly for including a script in multiple pages that has some html in it), but not for a whole template-style site.
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.
Last edited by djr33; 09-07-2009 at 07:38 PM.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
The Following User Says Thank You to djr33 For This Useful Post:
-
Many thanks to all.
Great ideas.
-
-
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/s...ad.php?t=47256
It may or may not suit your needs but its certainly a starting point.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks