473,395 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Anything in php like Rails @content_for_layout

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
Jul 10 '07 #1
2 1591
On Jul 9, 8:29 pm, "RVince" <r vince 9 9 at hotmail dot comwrote:
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
include() and require():

<http://www.php.net/include>
<http://www.php.net/require>

Jul 10 '07 #2
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_con tents('$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
Jul 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: flab ba | last post by:
The pragmatic programmers (Dave & Andy) are spreading a good word about RubyOnRails. I was wondering if there are any Python programmers who are /also/ familiar with Rails - and if they could...
2
by: Jeff Blaine | last post by:
Like many people, I've recently been turned onto "Ruby On Rails" (I believe it was a Slashdot article release announcement recently) and didn't know it existed before then. I've been writing...
12
by: Gary Nutbeam | last post by:
I've noticed that the Perl camp has a very nice web/database environment called Maypole. Ruby has the Rails environment which on the surface seems similar to Maypole. I can't find anything in...
28
by: flamesrock | last post by:
Firstly, this topic is NOT intended for trolling or starting any flame wars. I want to know if anyone has experience with these frameworks, and if so, how do they compare? Which one do you...
122
by: seberino | last post by:
I'm interested in knowing which Python web framework is most like Ruby on Rails. I've heard of Subway and Django. Are there other Rails clones in Python land I don't know about? Which one...
44
by: John A. Bailo | last post by:
Dr. Dobbs has a /glowing/ article on Ruby on Rails this month. What do you guys think? Can it replace .net, php and java? And be the Open Source OOP web solution that is not bound to Sun or...
92
by: Ray | last post by:
I just moved to another company that's mainly a Java/.NET shop. I was happy to find out that there's a movement from the grassroot to try to convince the boss to use a dynamic language for our...
42
by: kenneth.m.mcdonald | last post by:
First, I don't intend this to be a flame war, please. Python and Ruby are the only two languages I'd willingly work in (at least amongst common languages), and TurboGears and Rails seem roughly...
10
by: lawrence k | last post by:
I work mostly in PHP, but at the web design firm where I work we are thinking of switching to Ruby on Rails. Our lead designer recently installed Typo on a client's site and he said to us, with...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.