Re: templates with php
| From: | Rasmus Lerdorf | Date: | Tue, 01 Aug 2000 00:30:10 +0000 |
| Subject: | Re: templates with php | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-9322@lists.php.net to get a copy of this message | ||
> > > I myself have worked with other web designers who can't (won't) even write
> > > html, and do everything in a visual editor like GoLive or DreamWeaver. For
> > > them, adding in a {$title} placeholder in plaintext in the visual
> > > environment would be a lot more comfortable conceptually than <?=$title?> in
> > > the html-view of the same page. Actually, dragging a {$title} icon to the
> > > layout would be even better :)
> >
> > Actually, DreamWeaver and HomeSite both support PHP tags now and you can
> > build macros and actually drag these <?=$title?> tags around
> > correctly. And these PHP tags will be correctly handled by these tools
> > and treated as special markup tags.
>
> Hi,
>
> Using php it's pretty easy to let your coders write their variables how
> they like. For example, if you page designer likes to use '@VAR@', use
> the script:
>
> <?php
>
> $file = BLAH;
>
> if (!($ifp = fopen($file, "r")))
> die("Could not open '$file' for reading\n");
>
> if (!$ofp = fopen("$file.php", "w"))
> die("Could not open file '$file.php' for writing\n");
> fputs($ofp, ereg_replace("@([a-zA-Z]+)@", "<?=\$\\1;?>",
> fread($ifp,
> filesize($file))));
> ?>
>
> Then if they save their file w/out an extension, this converts it to a
> .php file with the @VAR@'s converted to <?= $VAR; ?>.
>
> Of course, using preg_replace, you can do any amount of converting --
> you can give them a wholly simply "while" loop syntax, etc.
>
> You can either give them a button to do the conversion or have a script
> poll the development directories every second and do a conversion on any
> file which is newer than its .php equivalent.
Yeah, I actually set something like this up before as well. Except I did
the conversion during cvs checkin time. And converted it back when they
checked the pages back out.
-Rasmus