Anything in php like Rails @content_for_layout

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RVince

    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_la yout. 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_la yout 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


  • ZeldorBlat

    #2
    Re: Anything in php like Rails @content_for_la yout

    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_la yout. 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_la yout 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>

    Comment

    • gosha bine

      #3
      Re: Anything in php like Rails @content_for_la yout

      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_la yout. 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_la yout 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($pat h) {
      ob_start(create _function('$c', "
      return
      str_replace('@c ontent_for_layo ut',\$c,file_ge t_contents('$pa th',1));
      "));
      }


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

      use_layout('lay out_filename.ht ml');



      --
      gosha bine

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

      Comment

      Working...