You are here: Re: Anything in php like Rails @content_for_layout « PHP Programming Language « IT news, forums, messages
Re: Anything in php like Rails @content_for_layout

Posted by gosha bine on 07/10/07 10:43

On 10.07.2007 02:29 RVince wrote:
> I am wondering if there is a means in php to mimic what, in rails, is called
> @content_for_layout. Essentially, that tag in rails can be placed in an html
> page, and, anytime a page (any page in a project) is to be rendered, the
> html page is displayed and the @content_for_layout part is replaced with the
> rendered script of the page being called.
>
> Its a nice feature wherein you can retain header, footer, frame, css stuff,
> in one spot. Do we have anything like this in php or is anyone aware of
> something out there that would essentiually do a similar thing? Thanks,
> R.Vince
>
>

There's no built-in function for this, but it's easy to write one.


function use_layout($path) {
ob_start(create_function('$c', "
return
str_replace('@content_for_layout',\$c,file_get_contents('$path',1));
"));
}


To "wrap" some script's output in a layout, just write this at the
beginning of the script:

use_layout('layout_filename.html');



--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация