|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
HTML Templates
Well looking around at alot of other peoples coding they do so much better than me...One of the problems is I have yet to figure out how to make HTML templates like people are doing.
here is an example of what I am talking about. PHP Code:
The only thing I droped out was the enbeded css...Now if you look at this on a website it looks like this. PHP Code:
I took the css out of this as well. Notice were it says "{website_title}" all the things in brackets....How the heck did something get into there? Is their a tutorial on this...In all my reading I have yet to find anything. Sorry it is so long and wide....PLEASE HELP I know this will make my life easier.
__________________
Thanks, Attila http://www.glorynaspiration.com http://www.abitofthings.com |
|
#2
|
|||
|
|||
|
First, the templates are read into a scalar. From there, it is regular expressions that does the data replacing, as so ->
PHP Code:
For each page element, you would typically have a function to create that element. The funtion would build the element and you would use a preg_replace() to replace the tpl tag with the data that is generated from the function -> PHP Code:
__________________
~ Joe Penn We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set? Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you. |
|
#3
|
|||
|
|||
|
More Questions
Ok I have messed with it but I haven't done it your sugested way. I have the pages inside a database not sure if that is the best way but it is what I have done.
here is what I have. PHP Code:
My functions that I have questions about. PHP Code:
This code in the Function. PHP Code:
Is actually inside a database for all the links. How do I make it cycle through to the end of the database pasting each individual link? I beleive I have to put it into an array but not sure how to read my database to an array. here is the html file. PHP Code:
If I put {headerlink} in the html multiple times it only replaces the one value. So how do I do this. Hope this makes sence to someone so I can get some help. |
|
#4
|
|||
|
|||
|
Well, thats alot of code to look through. You want to first grab all of the HTML out of the database, bind it to one scalar instance (not array) and do the preg_replace() on the one block. If you do the preg_replace() on the one block and do not include an int LIMIT for the preg_replace(), it will replace all instances with the replacement.
Is that what you are looking for - I am not following your post to much...? EDIT::: How do you have your DB setup. Do you have a table with your template and each field holds a certain html block of code? Or do you have a table for each block? How is the structure, post it so we can see.... |
|
#5
|
|||
|
|||
|
As of now I was creating a table for 1 piece of code. Then echoing them to the webpage. Not sure if that is the correct way...I am going to change it to the page being all in one table Would like to be able to skin things so what would be the best way...
Sorry after hours of work I figured out the other problem! |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > HTML Templates |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|