Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7707903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:28:35+00:00 2026-06-01T00:28:35+00:00

I’m using Drupal 6 and have created 2 equal columns in layout.css In the

  • 0

I’m using Drupal 6 and have created 2 equal columns in layout.css
In the left column I have a view with a list of nodes.
Each node has an attached view with a list of it’s child nodes (using views attach and a node reference argument).

I would like to be able to click a link on each of these left column nodes and bring up it’s child view in the right column using ajax.

I’ve tried placing jquery/javascript in the head of the node-xxx.tpl.php calling the viewsattach via an external page named ajaxview.php ie:

<script type="text/javascript">
Drupal.behaviors.ajaxview = function(context) {
$("#ajaxclick").click(function(){
        $("#container").load("http://path/to/ajaxview.php 
        });
}
</script>

<a id="ajaxclick" href= "#">Click me</a>
<div id="container"></div>

And in ajaxview.php :

<div id="rightcolumn"><?php print $node->content[Comments_node_content_1]['#value'];?></div>

I get nothing but a blank page…

How can I get a child view to appear in the right column whenever a node in the left column is clicked?

Is there a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:28:36+00:00Added an answer on June 1, 2026 at 12:28 am

    Your ajaxview.php file is not in the same context as your code in node-xxx.tpl.php and that means that it does not have access to $node variable. Your ajaxview.php file is executed as a new script, probably outside Drupal if you really named it ajaxview.php.

    You should consider creating a path in your menu hook and call that path with ajax in your node-xxx.tpl.php.

    <?php
    
    function test_menu() {
      $items = array();
    
      $items['myajax'] = array(
        'title' => 'My Ajax',
        'page callback' => 'test_myajax',
        'description' => 'Test',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
      );
    
      return $items;
    }
    
    
    function test_myajax($nid) {
      $node = node_load($nid);
      print '<div id="rightcolumn">';
      print $node->content['Comments_node_content_1']['#value'];
      print '</div>';
      exit();
    }
    

    This code will create a new path “myajax” (which you should rename to something more meaningfuyl to you) which should be called with a node id like this:

    http://yoursite/myajax/999
    

    where 999 is the node id.

    This means that in your code that calls the ajax, you should pass the nid of the current node being viewed. There are different ways of doing this, depends on your context.

    Here is a sample javascript that works with the code above (I tested it local).

    <script type="text/javascript">
    Drupal.behaviors.ajaxview = function(context) {
        $("#ajaxclick").click(function(){
            $("#container-test").load(Drupal.settings.basePath + "myajax/" + 999); 
        });
    }
    </script>
    
    <a id="ajaxclick" href= "#">Click me</a>
    <div id="container-test"></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.