In the 2.x version, we have hook homebox to enable a page to live in code. It would be great to add additional hooks to process, display and save data defined by these hooks OR to override data generated by the homebox module itself.

I am writing a module to enable users to "Add RSS feeds" to their home box much like "Add Item", without changing any code in the homebox module. I can provide the UI for users to add RSS feeds by overrideing the homebox.tpl.php and having additional js in my custom module to do the dialogs. But, saving & presentation of the RSS feed cannot be done without changing the homebox code itself. Adding API's/hooks to homebox would help module developers, using homebox to develop widgets easily.

Comments

mstef’s picture

That's a very excellent point. Why don't you take some time, and document for me, what you think should be in there, from another developers perspective. I'd love to get this in there..

abrao’s picture

Will do. Give me a few days to get back to you.

mstef’s picture

No problem. Thanks.

mstef’s picture

Any thoughts yet?

mstef’s picture

Status: Active » Postponed (maintainer needs more info)
nibo’s picture

Could I suggest Feeds integration?
I don't have any idea if that is possible at all, but it would be very powerful. It would support not only the import of RSS Feeds, but also iCal and CSV. So let's say I have the iCal Feed of some company I'm currently working with, but I don't want to to import all their events to my calendar, just want to have a seperate homebox block, where I could track their events. This could be one use case ...

mstef’s picture

Feeds integration would be a separate feature request. I'm assuming that you can produce blocks/views that contain the data from Feeds. If that's the case, you can simply add the block to a Homebox.

nibo’s picture

Hey Mike,

yes, that can be done, but it would be possible only for the admin, or am I missing something? My idea was more from a user perspective. As addition to the cool widget adding functionality through "Add Item" right now the user could be able to select the type of the import from a drop-down list (Widget, RSS Feed, iCal Feed and so on) and if a feed is selected, then the content field would be the URL of the feed...
I don't know if it makes sense at all, it was just a spontaneous idea :) If it's silly just ignore it :)

Greets
Nikolay

mstef’s picture

That is interesting. I like the idea. But I think it should be the work of the Feeds maintainer to create a block or something that allows users to do that - as this seems like a good feature to have with or without Homebox. Have you tried making a feature request over there?

pheraph’s picture

Hi,

I installed the Feeds-Module and used Views to create a block that accepts a node ID (to be precise the feed ID) and displays a list of the related feed items (that's no rocket science). Now if Homebox offered a dialog which allows to select a block and pass a parameter to it, the feed integration would basically be done. The advantage of this method would be that it is not limited to the Feeds-Module, through this interface other modules could be integrated with homebox. It shouldn't be too difficult to let the user select from a list of block and pass a parameter to it, should it?

Raphael

mstef’s picture

Hi,

Well again, this thread is about adding hooks to homebox - not Feeds. You should open up another issue if you want to discuss that. I'm not sure how hard it would be. It wouldn't be easy and quick - I know that. I've never even opened up the Feeds module. I can say though, that this is not something I'll be doing now. If you or another developer want to take a stab at it, I'd love to check out the work.

brianV’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev

Bumping version as 6.x-2.x is no longer being developed.

Dustin@PI’s picture

Status: Active » Postponed (maintainer needs more info)

My team created a module that does exactly what @runhrun suggested (i.e. a configurable rss homeblox block).

Using the current version of Homebox it's pretty easy to create a block with additional settings via "hook_homebox_block_edit_form"/"hook_homebox_block_keys".

I would say this was done ... except now I see a need to be able to set a default value for the keys in hook_homebox (i.e. so we can set the value that we want for homeboxes that are set on the page by default)

Example of what I am suggesting ...

function myexample_homebox() {
    $pages = array();
  
    $pages['testbox'] = array(// Keyed with the unique machine-name
      'title' => 'Test Homebox', // The title of the Homebox page
      
      ... bunch of settings

      ),
      'blocks' => array(// The available blocks on the page
        'myexample_rss' => array(// The block key; Format = module_delta
          'module' => 'myexample', // The module this block belongs to
          'delta' => 'rss', // The block delta
          'region' => 2, // Which region to place this block in
          'movable' => 1, // Can this block be dragged?
          'status' => 1, // Is this block visible by default (if not, it can be toggled)?
          'open' => 1, // Is this block expanded by default?
          'closable' => 1, // Can users close this block?
          'title' => '', // Blank if default block title should be used, if not, use a custom one
          'weight' => -8, // The weight of the block (lower numbers raise to the top)
          //here's the new part!!!!!
          'default_settings' => array(//set the default form values for this homebox block
              'rss_url' => 'https://drupal.org/project/issues/rss/homebox', 
              'items_per_page' => 7
          ),
        ),
Dustin@PI’s picture

Version: 6.x-3.x-dev » 7.x-2.x-dev
Status: Postponed (maintainer needs more info) » Active
Dustin@PI’s picture

Component: Code » Documentation
Assigned: Unassigned » Dustin@PI
Category: feature » task
Status: Postponed (maintainer needs more info) » Active

Did some digging to see if I could whip up a patch and it already works!

example

function myexample_homebox() {
    $pages = array();
  
    $pages['testbox'] = array(// Keyed with the unique machine-name
      'title' => 'Test Homebox', // The title of the Homebox page
      
      ... bunch of settings

      ),
      'blocks' => array(// The available blocks on the page
        'myexample_rss' => array(// The block key; Format = module_delta
          'module' => 'myexample', // The module this block belongs to
          'delta' => 'rss', // The block delta
          'region' => 2, // Which region to place this block in
          'movable' => 1, // Can this block be dragged?
          'status' => 1, // Is this block visible by default (if not, it can be toggled)?
          'open' => 1, // Is this block expanded by default?
          'closable' => 1, // Can users close this block?
          'title' => '', // Blank if default block title should be used, if not, use a custom one
          'weight' => -8, // The weight of the block (lower numbers raise to the top)
 
          //custom settings:
          'rss_url' => 'https://drupal.org/project/issues/rss/homebox', 
          'items_per_page' => 7, 

          //color Works too! (needs to be a hex ... doesn't need to match the ones defined for the page)
          'color' => '00cc77',       
        ),
Dustin@PI’s picture

Component: Documentation » Code
Assigned: Dustin@PI » Unassigned
Category: task » feature
Status: Active » Postponed (maintainer needs more info)

Since the original request was a hook for doing something like "Add a feed" and various other extension points, I'm going to mark this back to postponed (maintainer needs more info).

I've created a separate issue #2074731: Document hook_homebox in homebox.api.php to update the documentation so that doing what I described above is easy to discover without having to read so deep into the code.

Dustin@PI’s picture

Back to original request (adding additional hooks for developers) it would be useful if there was a hook for tinkering with (altering) the initial settings for a user. This could be useful in a number of scenarios: adding different default blocks by role or by person taxonomy.

It would be something like "hook_homebox_initial_user_settings_alter". I'm not sure if this actually should be an alter ... but it seems to be the easiest. Proto-type below ...


/**
 * Fetch user page settings, if they exist.
 *
 * @param $page
 *   A page object
 * @param $init
 *   Make sure the user object is fully initialized, not FALSE. Needed for
 *   adding/editing a single block.
 * @param $_reset
 *   Reload settings from the database.
 *
 * @return
 *   An object representing the user's page settings, or FALSE.
 */
function _homebox_get_user_settings($page, $init = FALSE, $_reset = FALSE) {
  global $user;
  static $cache = array();
  $key = $user->uid . ':' . $page->name;

  if ($_reset) {
    unset($cache[$key]);
  }

  if (!isset($cache[$key]) || ($init && $cache[$key] === FALSE)) {
    $settings = db_query("SELECT settings FROM {homebox_users}
      WHERE uid = :uid AND name = :name", array(':uid' => $user->uid, ':name' => $page->name))->fetchField();
    $cache[$key] = $settings ? unserialize($settings) : FALSE;

    if ($cache[$key] === FALSE && $init) {
      $user_blocks = $page->settings['blocks']
      drupal_alter('homebox_initial_user_settings', $page, $user_blocks); //$page is passed by val, $user_blocks by ref
      _homebox_save_user_settings($page, $user_blocks);
      $cache[$key] = _homebox_get_user_settings($page);
    }
  }

  return $cache[$key];
}

cockers’s picture

@ Dustin@PI - is that RSS block you discussed going to be added to a development version of the module? That's exactly what I'm looking for at the moment. I'd appreciate any help with that as my programming skills are very limited and that sounds like the kind of thing I'm looking for. Thanks for the hard work!

Dustin@PI’s picture

@cockers, I can split out the code and post it as a sandbox project. After that the Homebox maintainers can decide if they want to pull it in as as a sub-module.

It currently has a bunch of code that is specific to my site, so it will take a small amount of tweaks. When would you be looking to use it?

cockers’s picture

That sounds great. I'm definitely up for testing it - my site is still very much developmental so I'm in no rush so please don't feel as if you should be. That said, I can find time whenever it's available. Thanks again Dustin@PI, it's responses like that that make the Drupal community so great!

ptsimard’s picture

@Dustin@PI it seems I have a very similar use case on my end. Both the RSS feed block and possibly additional hooks. Where are you in your development process, did you overcome all hurdles?

My organisation requires many features to be piped through a personalised homebox page so I can see the next few months of my life being spent on the homebox module and integration. Still learning how homebox works right now.

drumm’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Closing due to lack of information.