Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Custom field in layout

I would like to use a custom field content in a layout, is that possible?

For example after adding "Backgorund image" custom field to pages I would like to insert its content in a layout.


  • Found:

    {{ extra->my_custom_field_name }} 

    it's great!

  • I would like to simulate the presence of the extra field, configured in the pages, so as to use the same layout in custom apps.

    Following the example above I would then set {{ extra->my_custom_field_name }} in the handler that uses the same layout used by pages.


  • Is that possible? Thanks.

  • If you mean you want to set a page's custom field from inside a handler, I would try this:

    $page->ext ('my_custom_field_name', 'Value for custom field');

    Let me know if that works.

  • It doesn't work for me.

    I get: Fatal error: Call to undefined method Page::ext()

    Perhaps we need to first assign an object to the extra property?


    $page->extra = (object) $wp->extra;
  • I solved with:

    $page->extra = (object) array ('bg_image' => '/files/design/bg-1.jpg');
  • Ah yes, the ext() method wouldn't work. admin/page converts a Webpage model into the Page object, which handles the page assets and rendering. Yours would be the right way to do it.

Sign In or Register to comment.