multiple nodes on same page, multiple containers - how to?

nk_ - May 16, 2008 - 13:23
Project:AHAH Forms Framework
Version:5.x-1.5-5
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I don't know if this was better to submit under jstools project or here. I am using both modules and I am sure that this isn't best approach but so far I came up to this and got stacked so I decided to ask for support... Thanks for any tip or help.

In my custom content node 'node-archives.tpl.php' I call this function:

print drupal_get_form('ahah_test_page', $nid)

Function is in my custom 'ahah_test.module'
It is jstools tabs form with #ahah_bindings on third (and should be also invoked on 4th and 5th) tab and that's in order to
avoid initial loading of bunch of content. I have a plan to display 10 nodes with tabs within one view (at the moment I am testing with only 2 nodes) and content called by ahah is yet another different view which holds central site database of items defined with terms ...

ahah_test.module

function ahah_test_menu($may_cache) {
  $items = array();
    if (!$may_cache) {
      $path = fetch_path();
      $items[] = array(
        'path' => $path['url'],
        'callback' => 'ahah_test_sample',
'type' => 'CALLBACK',
'access' => true,
     ); 
  }
return $items;
}

function fetch_path($opt = array()) {
  if (arg(0) == 'festival' && arg(1) == 'archives') {
    $opt['url'] = 'festival/archives/test_sample';
    $opt['wrapper'] = 'tabs-archives0-3';
  }elseif (arg(0) == 'node' && is_numeric(arg(1))) {
    $opt['url'] = 'node/' .arg(1) .'/test_sample';
    $opt['nid'] = arg(1);
    $opt['wrapper'] = 'tabs-archives-3';
    $opt['tid'] = '69';
}
return $opt;
}

function ahah_test_page($nid) {
 
  $node = node_load($nid);
  $options = fetch_path();
  $form = array();
   
  $form['archives'] = array(
      '#type' => 'tabset',
      '#ahah_bindings' => array(
            array (
                'selector' => 'ul.anchors.tabs.primary li#'.$title_screening.' a',
                'event' => 'click',
                'wrapper' => 'tabs-archives-3',
'path' => $options['url'],
'params' => array( 'tid' => '69'),

),
            array (
                'selector' => 'ul.anchors.tabs.primary li#'.$title_screening.' a',
                'event' => 'click',
                'wrapper' => 'tabs-archives0-3',
'path' => $options['url'],
'params' => array( 'tid' => '69' ),
),           
        ),
   );
  $form['archives']['production'] = array(
      '#type' => 'tabpage',
      '#title' => $title_production,
      '#content' => $value_production,
  );
  $form['archives']['awards'] = array(
      '#type' => 'tabpage',
      '#title' => $title_awards,
      '#content' => $value_awards,
  );

  $form['archives']['program'] = array(
      '#type' => 'tabpage',
      '#title' => $title_screening, 
      '#content' => '',
  );

  $form['archives']['program']['ahah'] = array(
     '#type' => 'item',
     '#prefix' =>'<div id="ahah-'.$nid.'">',
     '#suffix' =>'</div>',
     '#content' => '<span class="small">if you can\'t load this tab means that javascript is disabled in your browser. Go to this page to see this content</span>',
  );

return $form;
}

function ahah_test_get_view($tid) {
  //$limit = 3;
  $view_name = 'taxonomy_term';
  $view_args = array();
  $view = views_get_view($view_name);
  $view_args[0] = $tid;
return views_build_view('embed', $view, $view_args, FALSE);
}

function ahah_test_sample() {
  $tid = $_POST['tid'];
  print ahah_test_get_view($tid);
}

I have 3 problems with this
1. ) Content is loaded in each 3rd tab of each node when they are on views page.
How to assign unique div name for each node? I tried this with simple form item ahah with div 'ahah-'.$nid in prefix and unique divs are rendered in display but content is not loaded in both but in first one.

2.) 'params' => array( 'tid' => '69' ), doesn't work for me, i am sure i am missing something about it.

3.) last and less important, there is an issue with thickbox in ahah loaded content, i found http://docs.jquery.com/Tutorials:AJAX_and_Events and will have a better look about it when i am done with important things from above ...

Thanks for any response

#1

starbow - July 21, 2009 - 21:24
Status:active» closed
 
 

Drupal is a registered trademark of Dries Buytaert.