Issues in rendering the block on front-end
  • Hi admin,

    Here is my setup, I have created a page in the back-end which is mapped to a layout suppose 'my_layout'. All the fields are rendered properly in the front-end except for the block which is associated to one of the layout variables.
    Please find the below for reference:


    $config['layouts']['my_layout'] = array(

    'fields' => array(
    'Header' => array('type' => 'fieldset', 'label' => 'Header', 'class' => 'tab'),
    'page_title' => array('label' => lang('layout_field_page_title')),
    'meta_description' => array('label' => lang('layout_field_meta_description')),
    'meta_keywords' => array('label' => lang('layout_field_meta_keywords')),
    'Body' => array('type' => 'fieldset', 'label' => 'Body', 'class' => 'tab'),

    'heading' => array('label' => lang('layout_field_heading')),
    'page_active_top_menu' => array('type' => 'textarea','label' => lang('layout_field_page_active_top_menu')),
    //the below section is not rendered in the front-end
    'section_1' => array('type' => 'block', 'folder' => 'menu_folder'),

    'breadcrumbs' => array('label' => lang('layout_field_breadcrumbs')),
    'page_title_header' => array('label' => lang('layout_field_page_title_header')),
    'section_2_1' => array('type' => 'textarea','label' => lang('layout_field_section_2_1')),
    'section_2_2_class' => array('label' => lang('layout_field_section_2_2_class')),
    'section_2_2' => array('type' => 'textarea','label' => lang('layout_field_section_2_2')),
    'section_2_3' => array('type' => 'textarea','label' => lang('layout_field_section_2_3')),
    'section_3' => array('type' => 'textarea','label' => lang('layout_field_section_3')),


    'body' => array('label' => lang('layout_field_body'), 'type' => 'textarea', 'description' => lang('layout_field_body_description')),
    'body_class' => array('label' => lang('layout_field_body_class')),
    )
    );

    //here is the block field description
    $config['blocks']['menu_block'] = array(
    'fields' => array(
    'page_active_top_menu' => array('type' => 'textarea','label' => lang('layout_field_page_active_top_menu')),
    'sub_menu_container_class' => array('type' => 'textarea','label' => lang('layout_field_page_active_sub_menu_class')),

    'background_image' => array('type' => 'file','label' => lang('layout_field_backgroundbanner')),
    'background_banner_url' => array('type' => 'text','label' => lang('layout_field_background_banner_mob_url')),
    'backgroundmob_image' => array('type' => 'file','label' => lang('layout_field_backgroundmobbanner')),
    'background_banner_mob_url' => array('type' => 'text','label' => lang('layout_field_background_bannermob')),
    'active_menu' => array('type' => 'textarea','label' => lang('layout_field_page_active_sub_menu')),

    'banner_text_content' => array('type' => 'textarea','label' => lang('layout_field_page_banner_text_content'))
    )
    );


    After the above code, I am able to save the block variables in the admin panel at the page level, but I am not able to see the block code being rendered.
    Note: I have tried with have the file inside _blocks/menu_folder/menu_block.php, also I have tried removing the file from the _blocks folder and having an admin driven block created from the admin panel named menu_folder/menu_block but in both the cases I am not able to see the html rendered.
  • The block field will create an array variable with the name of the variable being the name of the field (e.g. menu_block), the keys being the field names, and the values being the values submitted in the form:
    <?=$menu_block['page_active_top_menu']?>
    Does your layout / view file have that variable passed to it?
  • Does your layout / view file have that variable passed to it?
    I am using the admin panel for passing data, the only code that I am using is the above my_fuel_layout.php code shared.

    So you suggest that for accessing the variable values inside the blocks HTML code, I have to use the variable as
    {$menu_block['variable_name']}
    right?
  • Yes. The block field type saves variables as a key/value array.
  • I sorted the Issue, I was trying to call the section_1 in my layout file like we call general fuel_vars.
    <?php echo fuel_var('section_1'); ?>

    instead when I replaced the above code with the one below, things worked
    <?php echo fuel_block('menu_folder/'.$section_1['block_name'],$section_1); ?>


    Thanks Admin..

Howdy, Stranger!

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