I would welcome suggestions on how to update 20 or so pages on a weekly basis without copying and pasting content and some code to every page. I change an element "Next Event" & an accompanying "Enviro Quote" frequently, and manually updating and proofing every page takes much too long and, in my hands, is subject to error.

I am untrained in this stuff but do my best to create the web sites for a couple of charitable organizations I belong to. As a result in spite of my best efforts to keep formatting in a CSS, code creeps back onto the html page - so I apologize for the dogs' breakfast lying behind my site!

The link is www.conservancyonmayne.com and the left sidebar of every page needs to be updated with event information - a thumbnail poster linked to screen readable version and text linked to a fuller description of the event together with a relevant quotation.

I would like to populate this element just once, as if content could be lodged within a <div> defined in a style sheet - and I think I've found that cannot be done! On the other hand I am much too ignorant and our organizations much too poor to indulge in a database driven redesign of our sites.

Is there a simple way to achieve this problem of recurring, changeable content?

Thank you for any suggestion!


Recommended Answers

All 4 Replies

given a host that allows any server scripting, most do either php or asp, for ease this is a php scrap

one line in each file affected by the change

<?php include('pathto/filename'); ?>

where filename is the file containing the html of the changed information

incidentally ALL repeated content can be done similarly
a page is

<?php include{'pathto/header');
include('pathto/filename'); ?>
<div> content unique to this page</div>
<?php include{'pathto/footer'); ?>

a heck of a lot less typing

everything in the header,,,

<link rel stylesheet>
<script type='text/javascript'>

everything in the menu,,,

><ul class'menu'><li><li><li></ul>

everything in the left column
everything in the changeable file
everything in the footer

is common to all the pages of the site

Thank you for the php include syntax. I can see that this will work well for me. However I am having difficulty in making it work.

Do the file(s) to be "called" by the include have to be named with the extension ".php" and do the container files (those that are going to use the "include" files - in my case next_event.php and next_quote.php - assuming that is the extension required as opposed to htm or html) need to have the .php extension?

Does there need to be any entry in the "container" files' headers to alert the system to upcoming php instruction?

My hosting service assure me that my account is php enabled and that the script will execute from anywhere. Another account using the same service executes a php script to control access to a "member" page. The strange thing is that when I name the container file "test.htm" my browser displays the file correctly but the "include material" does not appear. When I rename the file to test.php and attempt to load it into my browser it declares that loading is "done" but absolutely nothing is displayed.

Thank you for your patience but I do need more help with this!



the file containing the php commands must be named with the .php extension
so the file index.html becomes index.php
the included file can be named ralph, .*html, *.inc, *.txt anything you want
the extension .php alerts the php interpreter, the same way as .html .htm alerts the html parser

the php 'hello world' http://php.net/manual/en/tutorial.php

Thank you for your help. This "update" cycle is working via the "include' statement - excellent.

Marking it Solved


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.