Since nedjo looks like he's pretty darn busy, I thought I'd post in the forums to see if anyone else out there can help me out.

- view this issue -
From the issue:

I would like to be able to use this module with thickbox so that I can display a node within a thickbox. Inputting node/21 (for example) does not work with thickbox because it tries to load the page theme as well and goes into a loop. I thought a good option would be to use pagearray.module in order to get a node's data and then display that in a thickbox of my own style. However, thickbox works by using what is in the href of the a.thickbox to get what you need into the thickbox. So in order to execute the pagearray_page function that pagearray.module provides, pagearray also would need a hook_menu implementation that could pass the $path variable as a callback_argument. I'm unsure of the best way to accomplish this, but I'm thinking it would be good to use something like /pagearray/node/21 in the anchor's href. (<a href='pagearray/node/21' class='thickbox' rel='gallery'>[link image]</a>)

Here is what I've put into the pagearray.module so far, but could use a little direction since this isn't working.

/**
* implementation of hook_menu
*/
function pagearray_menu($may_cache) {
  if ($may_cache) {
    $items = array();   
   
    $items[] = array(
      'path' => 'pagearray/'. arg(1) .'/'. arg(2),
      'callback' => 'pagearray_page',
      'callback arguments' => arg(1) .'/'. arg(2),
      'access' => TRUE,
      'type' => MENU_CALLBACK,
     );

    return $items;
  }
}

Comments

Island Usurper’s picture

'callback arguments' is kind of funky in that it takes an array as a value. I think it has something to do with the total number of arguments to the callback function and the number it expects. Something about merging the argument arrays.

Try this

//...
  'callback arguments' => array(arg(1) .'/'. arg(2)),
//...

You might also want to put in some extra items to handle the case when there is no second argument to pass. I'm not familiar with pagearray, so I don't know how robust or forgiving it is.

-----
Übercart -- One cart to rule them all.

nevets’s picture

First, as you have defined it you would want it to be part of ! $may_cache since the args can change.
Also the callback args need to be an array. Since arg(1) and arg(2) reflect the current path and not the link you are constructing you need another approach, In my example I assume you are always interested in a node. I would do it like this

<?php
/**
* implementation of hook_menu
*/
function pagearray_menu($may_cache) {
  if ($may_cache) {
    $items = array();  
  
    $items[] = array(
      'path' => 'pagearray/node',
      'callback' => 'pagearray_getnode',
      'access' => TRUE,
      'type' => MENU_CALLBACK,
     );

    return $items;
  }
}

function pagearray_getnode($nid) {
  return pagearray_page("node/$nid");
}
?>

Your links are of the form you described pagearray/node/N where N is a nid

sirkitree’s picture

What I ended up doing, after some direction from nedjo, is to use the dynamicload.module that is part of javascript tools. This has an example of how to use the pagearray.module without needing to modify it. This returns the node in JSON format, but I can work with that. So instead of trying to add my own hook_menu into the pagearray.module, I've changed my link to use dynamicload.module like so (<a href='/dynamicload/js/node/21' class='thickbox' rel='gallery'>[link image]</a>).

Thanks for the replies. Both taught me something more about module building.


~Professional: Lullabot
~Personal: jeradbitner.com