Forum Moderators: coopster

Message Too Old, No Replies

template into content

Wrapping a template around existing html code?

         

Josefu

11:41 am on Feb 23, 2006 (gmt 0)

10+ Year Member



I've cleaned a whole site of 1995-era html into xhtml, but now would like to strip all its 'excess' (headers, footers, ad and spacer columns, etc) away to insert it into a php template. The thing is, I don't want to disturb the existing site map.

Would it be possible to designate a page's 'stripped content' as a variable, and call a (say, three column) template containing that variable -or in other words, have a page's content written into a called template - on the same page?

Thanks for any help in this.

jatar_k

6:13 pm on Feb 23, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



yes you could do exactly that

another thought would be to move all code that comes before your content into one file and all code that comes after into another.

then just run through your pages, cut the top off and add an include for your header file, then cut off the bottom and add an include for your footer.

Josefu

6:34 pm on Feb 23, 2006 (gmt 0)

10+ Year Member



Hey, thanks for the reply.

The header-footer thing is easy as pie for sure, but what makes things complicated is a 'floating three-column' layout present in the 'body' of many pages - the 'stripped' former-html content will be going into the centre <div>, but the outer columns will be menus and ads.

I did find one solution - wrapping the 'stripped html' content block of code into a 'content()' function - then echo(ing) content() in the 'target <div>' in the template. This seems to work - Perhaps I've come up with an original something, but in my inexperience am not sure if it is commonplace or not. If there is a better solution out there ('same-page' inclusion into a called-for-inclusion-within-the-same-page-template), please let me know!

PS: is there any way of transforming a block of html code into a variable instead of a function? In your reply it sounds as if this is so... thanks!

jatar_k

6:39 pm on Feb 23, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> transforming a block of html code into a variable

you could probably use Heredoc [php.net]

>> wrapping the 'stripped html' content block of code into a 'content()' function

that method is fairly common