[TxMt] Persistent Includes?
Lewis Overton
akakie at gmail.com
Sat Mar 4 01:07:34 UTC 2006
On 3/3/06, Eric O'Brien <ericob at possibilityengine.com> wrote:
>
> I just want the convenience, when I'm
> building it, of having repetitive parts that are common to many pages
> located in only ONE place.
>
> While I don't know PHP, I bet I can figure out how to get include()
> to work for this simple case.
My personal rule is NEVER code it twice except for the minimal structure.
Anything which might change goes in a separate file, all managed within a TM
project. Files get included with PHP one-liners:
<?php @ require_once ("navbar.inc"); ?>
Shows up in every page, but to change navigation, I change it only in one
place. It is essentially an Apache server side include using in php.
Here is another one. This defines a dropdown menu in a sidebar.
<div id="navcontainer">
<form method="post" action="" >
<p>
<select name="list1">
<option selected="selected" value="060315">Choose
date</option>
<option value="060315">Mar 2006</option>
<option value="060206">Feb 2006</option>
<option value="060109">Jan 2006</option>
<option value="051205">Dec 2005</option>
<option value="051102">Nov 2005</option>
</select>
<input type="hidden" name="_submit_check" value="1" />
<input type="submit" value="select" />
</p>
</form>
</div> <!-- navcontainer -->
The dynamic part is the list, of course, which makes up part of the file
name.
Then this code, on the main page, loads one of the sub files into the page.
<?php
if (array_key_exists('_submit_check', $_POST)) {
/* ... do something with the form parameters ... */
$page=htmlentities($_POST['list1']); }
?>
<?php @ require_once("board-$page.htmlf"); ?>
Not my original code, just adapted. Visit <http://communityband.org/> to see
it working. Look at the board archive or the program archive. After the
concert on Sunday the third use of this gets emptied.
Lewy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20060303/a5fa650d/attachment.html>
More information about the textmate
mailing list