Quote:
Originally Posted by mopek1
That's more what I'm leaning towards.
How does that work exactly? How do you input the code so that so many pages can be changed at once on an already built website?
Same question here as above. If you have 20 million static html pages, how then can you modify or change them all if they don't have any php includes or code that is common to all pages that can be modified in one file? Unless I'm misunderstanding.
|
Thanks for your questions.
It's all about building on a basic simple concept, but depending on how much you add in, the end result can be extremely dynamic - not necessarily in real time per user, but periodically updating over a longer term. You have slow moving data and fast moving data.
1) THE BASIC HTML PAGE WITH INCLUDES
So you start with <html> ... </html>
If HTML tags are all you use, that page will always look the same.
Actually, not necessarily. CSS is a great way to manage the esthetics of your page WITHOUT having to change your HTML. Just update your CSS with your "new look", and the rest takes care of itself.
You have several choices for "includes":
PHP INCLUDES:
When it comes to integrating PHP code with HTML content, you need to enclose the PHP code with the PHP start tag <?php and the PHP end tag.
The code you put into the PHP sections will determine what is visually generated and how much load/delivery time your code adds.
PHP can do calculations, server environment retrievals (date/time), and database lookups.
JAVASCRIPT INCLUDES:
The <script>... tag lets you put JS code in your HTML page, either directly or by including files of JavaScript.
JS, like PHP can do calculations, determine/render your page according to the user's browser/device, but unlike PHP, JS runs on the user's browser without adding load to the server.
DYNAMICALLY GENERATING HTML FROM A DATABASE AND SERVER SCRIPTS:
When you start making your HTML pages, you will probably use a page or text editor to insert all the HTML markup codes, plus any PHP and/or JS you want to add.
When you're done, you upload that page file to your server and then anyone with a browser can "see" your page.
Now imagine, instead of manually "typing" all the stuff in your HTML page, you create a database (like MYSQL or even just plat text files) and organize all the "shared" information you want on groups of your pages (like headers, menus, etc) as data in the database.
To do this, you need to really be clear on the overall structure of your website.
In many ways, this is what Wordpress does - all of your blog posts and categories, etc are saved in a MYSQL db, which is used by PHP scripts each time (unless the page is cached) a page is requested.
If your website has lots of pages where the information is pretty static, instead of rendering each page (at the expense of a server DB hit) in real time, one can write their own scripts in PHP or (my preference) Perl, that are run as an administrative (like once a day or week) tasks, either as CRON jobs or manually invoked from Shell (if it's best to keep an eye out for unexpected side effects, across thousands of pages).
So in this case, the actual "HTML files" are not typed and uploaded by you - they are actually created by the server, on the server, with careful provisions to replace the old pages with the newer fresh pages.
These server-written pages can enjoy the benefits of full access to databases (when they are created), and also code includes in the HTML pages. Even though the HTML pages are static, they can take advantage of includes for stuff that needs to be up-to-date for every page request.
This level of content generation works for ANY code pages. I have scripts that write PHP and JAVASCRIPT CODE from databases as well.
Server-generated pages/code is not for beginners, nor is it appropriate for all applications.
STARTING OUT:
Mock up you pages, and figure out which parts of them need to change regularly or adapt each and every time to a visitor request.
Those changeable parts can be handled by includes.
FOR COMPLETENESS:
You could just code the entire page as PHP (index.php vs index.html), with full access to what PHP offers, and use JAVASCRIPT and CSS to respond to the visitor's browser dimensions.
I've been writing code generator programs for decades, so I'm comfortable with my hybrid approach, but that's not say that using PHP for the whole shebang is not a good idea.
In the end, you, or whoever is going to maintain your site, needs to be comfortable with the development platform you choose (also why Worpress is so popular).
Good luck!