How can I understand function what make it work with node is:

function alinks_nodeapi(&$node, $op, $teaser, $page) {
  
	switch ($op) {
    case 'view':
    	
      $node_types = in_array($node->type, variable_get('alinks_node_types', array()), TRUE);
      
      if ($node_types) {
        drupal_add_css(drupal_get_path('module', 'alinks').'/alinks.css');
        $words = alinks_get_strings();
       
        if ($words) {
        	
      	  $node->content['body']['#value'] = alinks_make_links($node->content['body']['#value'], $words);
	    }
      }
      break;
  }
}

Somebody know how must be look like function for working with fields in views?

Comments

Anonymous’s picture

Assigned: solomenikm » Unassigned

OK I will try and answer.

First, in general Views does not have fields, but does output fields from other content types.

I am assuming you have a View which displays several nodes, and you want alinks to attach to the displayed content?

If this is the case, all you have to do is theme the view

You will need to create views-view--page.tpl.php in your theme directory, using the code provided as the default for this in Views theme information "Display Output". NOte this affects ALL views, so you may wish to use one of the alternative template names to limit applicability

Now you will need to edit the code from

  <?php if ($rows): ?>
    <div class="view-content">
      <?php print $rows; ?>
    </div>
  <?php elseif ($empty): ?>
    <div class="view-empty">
      <?php print $empty; ?>
    </div>
  <?php endif; ?>

to look like this

  <?php if ($rows): ?>
    <div class="view-content">
  <?php 
 $words = alinks_get_strings(); 
        if ($words) { 
                print (alinks_make_links($rows, $words)); 
            }
  ?>
   </div>
 <?php elseif ($empty): ?>
    <div class="view-empty">
      <?php print $empty; ?>
    </div>
  <?php endif; ?>

You can also do a similar thing if you want to apply to the header or footer

Please note the code is not elegant, as I am no coder, but it works for me

pindaman’s picture

this is NOT working for D7./

I really don't know php, but i got it wirking for Drupal 7.

create a views template "Style output"
paste standard php i there. Then replace

<?php print $row; ?>
with

<?php 
 $words = alinks_get_strings(); 
        if ($words) { 
                print (alinks_make_links($row, $words)); 
            }
  ?>
greg boggs’s picture

One way to do this is to output the body field in your view as a rendered entity.

greg boggs’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)