I have a custom node view that I have created to provide a list view for a streaming video gallery/podcast listing. The problem is that the $node->path only displays when I am logged in, so anonymous users don't actually get a link to the headsup of the video. Am I doing something wrong?

$node = node_load($node->nid);

//now we add the stylesheet...
drupal_add_css(path_to_theme() .'/views-list-frontpage.css');
  • print $node->path "> print $node->title

    print $node->teaser

  • Comments

    beekerstudios’s picture

    Here is the code again

    <?php
    $node = node_load($node->nid);
    
    //now we add the stylesheet...
    drupal_add_css(path_to_theme() .'/views-list-frontpage.css');
    
      <li>
      	
    	  <div class="video_view_thumb"><a href="/<?php print $node->path ?>"><img src="/images/video/<?php print $node->field_stream_url[0][value] ?>_thumb.jpg" alt="<?php print $node->title ?>"><div>watch video</div></a></div>
    	    <h3><a href="/<?php print $node->path ?>"><?php print $node->title ?><a></h3>
    	    <p><?php print $node->teaser ?></p>
        	<div class="float_clear"></div>
    </li>
    
    josesanmartin’s picture

    Use $node_url instead of $node->path

    José San Martin
    http://www.verinco.com/

    José San Martin
    http://www.chuva-inc.com/

    beekerstudios’s picture

    Putting $node_url doesn't work at all. I think this may be because I am grabbing the whole node and putting in $node. This was done per a cookbook article.

    I tried:
    $node->url
    $node->node_url
    $node->path (of course only admin can see that)

    When I do a print_r($node); I don't see the path attribute in the array for an anonymous user, but I do for an admin or logged in user. What's the deal? Is this a permissions issue?

    This is Drupal 5, I don't know if views is different on 4.7.

    josesanmartin’s picture

    Sorry I didn't answer it later.

    (you're using Drupal 5, right?)

    $node->url and $node->node_url doesn't exist.

    $node->path only works when someone with editing permission is logged. I'm not sure why, but I have already read a good explanation on that.

    $node_url works in node.tpl.php. Can't you put it there?

    What are you theming, after all? Is it a front-page view? Is it a node page? Is it a completely different thing?

    Regards,

    José San Martin

    José San Martin
    http://www.chuva-inc.com/

    beekerstudios’s picture

    It's a list view, it's pretty simple, but instead of attaching an image, I am just using a field I already set, and ftp the images by hand. I am using Drupal 5.1. Here is the contents of the view:

    $node = node_load($node->nid);
    
    //now we add the stylesheet...
      drupal_add_css(path_to_theme() .'/views-list-frontpage.css');
      
      ?>
      <li>
      	
    	  <div class="video_view_thumb"><a href="/<?php print $node->path ?>"><img src="/images/video/<?php print $node->field_stream_url[0][value] ?>_thumb.jpg" alt="<?php print $node->title ?>"><div>watch video</div></a></div>
    	    <h3><a href="/<?php print $node->path ?>"><?php print $node->title ?><a></h3>
    	    <p><?php print $node->teaser ?></p>
        	<div class="float_clear"></div>
      </li>
    

    In template.php I have this:

    function phptemplate_views_view_list_video_view($view, $nodes, $type) {
    	$output = '<ul id="video_view">';
      foreach ($nodes as $i => $node) {
        $output .= _phptemplate_callback('views-list-video_view', array('node' => $node));
      }
      $output .= "</ul>";
      return $output;
    }
    
    josesanmartin’s picture

    Oh!

    Well, in the "Edit View" page, add a field named "Link to Node" and theme it.

    I think it is enough.

    José San Martin
    http://www.verinco.com/

    José San Martin
    http://www.chuva-inc.com/

    beekerstudios’s picture

    http://drupal.org/node/66642

    In /modules/path/path.module I had to replace:

    function path_nodeapi(&$node, $op, $arg) {
      if (user_access('create url aliases') || user_access('administer url aliases')) {
    

    With this:

    function path_nodeapi(&$node, $op, $arg) {
      if (user_access('create url aliases') || user_access('administer url aliases') || $op == 'load') {
    
    josesanmartin’s picture

    Be careful with what you change in core.

    it is not broken at all.

      if (user_access('create url aliases') || user_access('administer url aliases')) {
        switch ($op) {
          case 'validate':
              ............
            break;
    
          case 'load':  //here: the $op == load is verified here
              ............
            break;
    
          case 'insert': 
              ............
            break;
      .............etc....
        }
      }
    

    $node->path is NOT shown to the public and there must be a reason for that.

    Have you tried to do what I have recommended to you?

    Open the "Edit View" page, add a field named "Link to Node" and theme the field.

    Regards,

    José San Martin

    José San Martin
    http://www.chuva-inc.com/

    beekerstudios’s picture

    I already did the "Link to Node" and when I do a print_r($node); still not link/path to the node, which is what I need.

    Since someone else suggested to do it, it seems like it's a common problem. Why don't I want people to see the url path? The whole point is to make sure they can, via the view. Explain how this could be exploited in a bad way, currently I don't see how it could be, since it's JUST the path, and nothing else.

    mnapthine’s picture

    Hey Guys I was also after a solution, needed to break apart the link and shove some HTML in the link tag, anyway maybe this will help:

    http://drupal.org/node/87223#comment-164474