Block Layouts v1

edited October 2013 in Share
I thought I'd try out the Block layout feature of Fuel as outlined here: http://docs.getfuelcms.com/general/layouts

Copying the code verbatim, I get 2 PHP errors in the view :

Message: Undefined variable: sections,
Message: Invalid argument supplied for foreach()

and the admin edit/create page shows nothing much for a page saved with the Test layout except:

Layout Variables
This is the test layout field.

Should there be something there? The block file "image_right.php" is in _blocks/sections/ so I think it should at least show that as an option?

Comments

  • edited 2:35AM
    There is a crucial line missing from the documentation which I've fixed. Add the following below $test_fields variable declaration:
    $test_layout->add_fields($test_fields);
    http://docs.getfuelcms.com/general/layouts
  • edited 2:35AM
    That helps a lot! - but on the 2nd tab ('Sections', now showing) there is an error:

    Fatal error: Cannot use object of type Fuel_block_layout as array in .../Fuel_layouts.php on line 162

    This is an exciting feature!
  • edited October 2013
    I've just posted a fix for that in the 1.0 branch. An alternative would be to use an array syntax like so which does work (note that it's a different block and is using a repeatable field):
    $config['blocks']['test'] = array( 'group' => 'Sections', 'label' => 'Two Column', 'fields' => array( 'two_column' => array( 'display_label' => FALSE, 'type' => 'template', 'fields' => array( 'url' => array('type' => 'link', 'label' => 'Link'), 'image' => array('type' => 'asset', 'folder' => 'images', 'multiple' => FALSE), 'content' => array('type' => 'textarea') ), 'class' => 'repeatable', 'add_extra' => FALSE, 'repeatable' => TRUE ) ) );
    This is one of my favorite new features. Makes FUEL very flexible and fast for setting up page layouts. Has saved us a ton of development time when creating new sites.
  • edited 2:35AM
    Wow! This is a monster feature! It ought to be on billboards! Great stuff!
  • edited 2:35AM
    I am loving the block layouts feature, as Gumster said, a monster feature.

    I was wondering though, instead of specifying the fields for the block, are we able to specify a model and have it pull the fields from there?
  • edited 2:35AM
    You can't at the moment. You would need to call the model's form_fields method and pass the returned array to the 'fields' value. It would also save the values to the fuel_pagevariables table and not the model's table.
Sign In or Register to comment.