PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Apr 06, 2020 9:31 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Html code in php
PostPosted: Thu Jun 28, 2012 9:25 am 
Offline
Forum Newbie

Joined: Thu Jun 28, 2012 9:10 am
Posts: 2
for a while i have been thinking of making the programming easier in php
not sure if this wil be the same for other users here but i kinda find this much more fun to program
instead of writing all ur html code over and over again i use snippets for blank html files or tables or body backgrounds and atributes

now for extending my knowledge i would like other users to help me in my script design. also i want to make it so that a user has a choice in my html file i am useing the $html['body-bg1'] wich is a body backround as inline css

so those options would make inline css styles then i use a kinda language system wich i edited to change when a user wants to to external css with a different template and then as 3the option but different for every website

a logged in user can choose his own template by editing his profile wich wil then be choosen or extracted by the mysql

now i am just as far as putting some html codes in html.php

this is how my blanck html page looks like

Syntax: [ Download ] [ Hide ]

/*
------------------
html index basic : our new html page looks like this

<?php
include_once 'html.php';
?>

<?php echo $html['doctype-1']; ?>
<?php echo $html['html-s'];?>
<?php echo $html['head-s'];?>
<?php echo $html['title']; ?>
<?php echo $html['head-e'];?>


<?php echo $html['body-s'];?>



<?php echo $html['body-e']; ?>

<?php echo $html['html-e'];?>
------------------
*/



 


as u can see they have an s or an e assigned wich says start or end

as for the include file is here

Syntax: [ Download ] [ Hide ]


<?php
/*
------------------
HTML VARS : atributes and elements
Created By Olivier De Cock
MrWeardo@hotmail.com
This is an example file
u can edit this in anyway add as much code as u like to help extend the
file.

i did not write the html code from my head and neither should u
all these examples can be found on the net i just used the code
to put them in varriables for php so websites can easy be edited
and provide a better script overvieuw when writing in php.

------------------
*/


$html = array();


// Basic doctypes
//The following DOCTYPEs are commonly used:
$html['doctype-1'] = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
//This declares the document to be HTML 4.01 Strict. HTML 4.01 Strict is a trimmed down version of HTML 4.01 that emphasizes structure over presentation. Deprecated elements and attributes (including most presentational attributes), frames, and link targets are not allowed in HTML 4 Strict. By writing to HTML 4 Strict, authors can achieve accessible, structurally rich documents that easily adapt to style sheets and different browsing situations. However, HTML 4 Strict documents may look bland on very old browsers that lack support for style sheets.
$html['doctype-2'] = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
//This declares the document to be HTML 4.01 Transitional. HTML 4 Transitional includes all elements and attributes of HTML 4 Strict but adds presentational attributes, deprecated elements, and link targets.
$html['doctype-3'] = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">';
//This declares the document to be HTML 4.01 Frameset. HTML 4 Frameset is a variant of HTML 4 Transitional for documents that use frames.
//Well u get the idea by now ofcourse u have many other doctypes older and newer etc ..


/*
------------------
HTML VARS : starting tags and ending tags
------------------
*/


/*
------------------
html index basic : basic html page looks like this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Page title</title>
</head>
<body>



</body>
</html>
------------------
*/



/*
------------------
html index basic : our new html page looks like this

<?php
include_once 'html.php';
?>

<?php echo $html['doctype-1']; ?>
<?php echo $html['html-s'];?>
<?php echo $html['head-s'];?>
<?php echo $html['title']; ?>
<?php echo $html['head-e'];?>


<?php echo $html['body-s'];?>



<?php echo $html['body-e']; ?>

<?php echo $html['html-e'];?>
------------------
*/



$html['title'] = '<title>Page title</title>';  // i have placed this in 1 line sind u never split them


$html['html-s'] = '<html>';
$html['html-e'] = '</html>';

$html['head-s'] = '<head>';
$html['head-e'] = '</head>';

$html['body-s'] = '<body>';
$html['body-e'] = '</body>';


//Place ur Atributes here
$html['body-bg1'] = '<BODY BGCOLOR="gray" TEXT="red" >';
$html['body-bg2'] = '<BODY BGCOLOR="black" TEXT="silver" >';

//ofcourse with some php skills u can assign logged in vallues or any other req to see different styles like lets say u want the file to check if user is online use the if else function and switch the case of bg styles or other atributes



//Place ur links here
$html['link-1'] = '<a href="http://www.example.com/" target="_blank">externallink</a><br />';
$html['link-2'] = '<a href="index.php" target="index.php">internallink</a><br />';


//Place ur html-comments here
$html['htmlcomment-1'] = '<!-- the page is ending --><h4>here we commented that the page is ending</h4><!-- ending of the page --><p>This article demonstrates the HTML code to hide your comments.</p>';





?>



 


so help is appreciated in expanding the file and examples


Top
 Profile  
 
 Post subject: Re: Html code in php
PostPosted: Thu Jun 28, 2012 1:04 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US
I think I get the concept, but am a little confused about why you use an array yet don't loop through it? It would be interesting to know what was in html.php too. Seems like you have two goals -- increasing productivity and allowing users to customize the look.

Are you interested in OOP solutions to page building?

_________________
(#10850)


Top
 Profile  
 
 Post subject: Re: Html code in php
PostPosted: Fri Jun 29, 2012 3:49 am 
Offline
Forum Newbie

Joined: Thu Jun 28, 2012 9:10 am
Posts: 2
it is indead to increase productivity
as for the html.php is the second file in post .
the html part is idd a bit simple but that is only to improve coding so that u can have many examples or tables links in 1 file and echood out in an entire project. whithout the hasle of cut past stuff in html or the need of placing html directly in php files.
this is why every idea and example is welcome also in the futher more languages are able to join the project .
perhaps if u can show an example of oop solution ?
any good examples shown could help me deside on how and to then realy start the full product.
also by using a file called html.php mysql.php and css.php everything a coder has ever used copied pasted etc could just be saved in those files and be reused over and over again .

also i think oop would be to difficult for must users that are going to use this framework or how its called becaus of the lak of programming skills there for i wanted to keep it simple maybe with an other include for layout etc with also again some examples as my goal would be to create something for the noobs among us to create stylish looking sites

again everything comes with an example and as many options as possible so that if a person looks at it can alter an example file any way he wiches and creates his own var to echo out to the browser for example

Syntax: [ Download ] [ Hide ]
$html['body-bg1'] = '<body background="background.jpg" bgcolor="black" text="silver" link="blue" vlink="#33CC00"alink="#FF0000" MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" LEFTMARGIN="0">';
 


example of the inline css option for the body almost every atribute is there now the rest is up to the user what he needs also he can make a body-bg2 with what he needs

by doing it this way it is a copy past in 1 file without having to re-write everything and u can use it to echo out in a diffent file for example home or index .php can have a differt look and u can organize your looks how u want it in the file if u comment this way u also know where this is used what every scripter basicly has to use for proper use are comments

Syntax: [ Download ] [ Hide ]
//index.php
$html['body-bg1'] = '<body background="background.jpg" bgcolor="black" text="silver" link="blue" vlink="#33CC00"alink="#FF0000" MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" LEFTMARGIN="0">';
 


Syntax: [ Download ] [ Hide ]
//home.php
$html['body-bg2'] = '<body background="background1.jpg" bgcolor="gray" text="silver" link="blue" vlink="#33CC00"alink="#FF0000" MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" LEFTMARGIN="0">';
 


and when opening the file in your brower perhaps a folder called examples witch will then open every example in the script (scripts)

lol staring to confuse myself in trying to explain. :s


Top
 Profile  
 
 Post subject: Re: Html code in php
PostPosted: Fri Jun 29, 2012 11:20 am 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US
I don't really know your target users, so I don't know if this is the best solution or not. I think that currently the best practice in PHP is to use a layout template filled in with partial templates. Using PHP templates allows presentation logic to stay in the templates. The page building View code is really just assembling template files.

_________________
(#10850)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group