Creating a way for templates

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Creating a way for templates

Post by blacksnday »

As php and content/logic is an endless discussion I am finally
throwing myself in this with my current coding project.

I have been dreading/wishing to get this completed for a while
now, and am finally forcing myself to work on it.

The below, is my 'Alpha' idea on how to have a start for
a system that will make css based design much easier
within php, and welcome (want) ideas on what I should
look at to do it differently.

First thing is I try to use CSS for design as much as possible,
which in turn would mean creating tag recognition within php
to use the css.

This is what I have thought of so far, but not sure how well it is,
and this isn't the full code... but excerpts to give an idea
of what I have worked on so far...

TAGS.PHP
This would hold all the css tag values that would be used by
the preg_replace within TEMPLATE.PHP:
(would eventually be Web-Adminable)

Code: Select all

$newstart = "<div id='showindexnews'>";
$newsend  = "</div>";
TEMPLATE.PHP
Converts tags to the css as well as hold
any values such as newsid etc...:

Code: Select all

$html = preg_replace("#\[news\](.*?)\[/news\]#i", "{$newstart}\\1{$newsend}", $html);
DISPLAY.PHP
This would hold any display functions
and keep them until they are finally called to be used
by DISPLAYNEWS.PHP:

Code: Select all

function displayNewTitles($sitename)
{
global $sql;
$query 	= "select * from table where published='1' order by did desc limit 100"; 
$result = $sql->query($query); 
do 
{
$title		= $sql->row[lova];
$string  		= "[news]{$title}[/news]";
$joetest		= submitTags($string, 1, 1, $siteurl, $directory, $imgalt, $vf);

echo $joetest;

}while($sql->next_row());
}
DISPLAYNEWS.PHP
Now I finally display the News Titles :

Code: Select all

displayNewTitles($sitename);
Post Reply