How to implement hook_hoembox() in custom module?

Created on 21 August 2015, over 9 years ago
Updated 21 February 2023, almost 2 years ago

I've installed homebox module version 7.x-2.0-rc1. I've also custom module.

I've vocabulary like 'category' which contains terms like 'type1', 'type2'. Every terms contains title and image fields. When i created a new term, a new block is added to block list which displayed term title and term image.

Then I need a homebox page which displayed only all term blocks. Every time the term is created, new term block should be added into this homebox page and it should be configurable.

Is any suggestions? I've tried in various ways, but i can't make this work. Even i could created block while creating term items. But how to do remaining functions?

How implement hook_homebox() to list blocks programatically?

I've tried this code:

function phponwebsites_homebox() {
  $pages = array();

  $pages['samplebox'] = array(
    'title' => 'Samplebox',
    'path' => 'samplebox',
    'menu' => 1,
    'enabled' => 1, // Enable or disable the page. Only admins can view disabled
    'regions' => 3, // How many regions to create (1-9)
    'cache' => 0, // Use the block cache, when available
    'full' => 0, // Disable theme regions so page can go full-width
    'custom' => 0, // Allow users to add custom items to the page
    'roles' => array(// Which roles can view the page. If none specified, no one can view
      0 => 'authenticated user',
    ),
    'color' => 1, // Allow users to change the color of blocks
    'colors' => array(// Which colors are available (Must be 6 options)
      0 => '#e4f0f8',
      1 => '#c4d5b4',
      2 => '#ecc189',
      3 => '#ec8989',
      4 => '#6b6b70',
      5 => '#4b97e5',
    ),
    'widths' => array(// (Optional) The width percentage of each region
      1 => 25,
      2 => 50,
      3 => 25,
    ),
    'blocks' => array(// The available blocks on the page
      'block_9' => array(
        'module' => 'block',
        'delta' => 9,
        'region' => 1,
        'movable' => 1,
        'status' => 1,
        'open' => 1,
        'closable' => 1,
        'title' => 'test block for GT',
        'weight' => -15,
      ),
      'block_7' => array(
        'module' => 'block',
        'delta' => 7,
        'region' => 2,
        'movable' => 1,
        'status' => 1,
        'open' => 1,
        'closable' => 1,
        'title' => 'test block for HD',
        'weight' => -15,
      ),
      'block_8' => array(
        'module' => 'block',
        'delta' => 8,
        'region' => 3,
        'movable' => 1,
        'status' => 1,
        'open' => 1,
        'closable' => 1,
        'title' => 'test block for PD',
        'weight' => -15,
      ),
    ),
  );

  return $pages;
}

But i couldn't make this work?

πŸ’¬ Support request
Status

Closed: won't fix

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States phponwebsites

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Please create a new Drupal 8+ (3.0.x) issue, referencing this one, if this is
    still relevant for Drupal 8+ (3.0.x).

    As this issue was created for Drupal 7 which is close to EOL and won't
    receive any new features here anymore (unless someone implements them or
    sponsors development) I'm closing this issue for cleanup now.

    If anyone works on this or has a solution, feel free to reopen! πŸ˜„
    Thank you.

Production build 0.71.5 2024