Hi I was able to use the Theme Wizard in Views to get that lovely code out and customize how my views layout will look like..

now what I am interested in is to add a number at the end of links in my list views

example the links generated by views to the nodes are the following
<a href="/Drupal5/en/node/1">BMX</a>

what I want to have in that nice html link is to add a letter or a number at the end when the list of urls are generated

so the link will look something like this
<a href="/Drupal5/en/node/1/a">BMX</a>

the "a" is not part of the generated url.. I want to add it manually,
is that possible or not?
here is the code for my views in the template.php file

/**
 * views template to output a view.
 * This code was generated by the views theming wizard
 * Date: Fri, 04/18/2008 - 14:13
 * View: media
 *
 * This function goes in your template.php file
 */
function phptemplate_views_view_list_media($view, $nodes, $type) {
  $fields = _views_get_fields();

  $taken = array();

  // Set up the fields in nicely named chunks.
  foreach ($view->field as $id => $field) {
    $field_name = $field['field'];
    if (isset($taken[$field_name])) {
      $field_name = $field['queryname'];
    }
    $taken[$field_name] = true;
    $field_names[$id] = $field_name;
  }

  // Set up some variables that won't change.
  $base_vars = array(
    'view' => $view,
    'view_type' => $type,
  );

  foreach ($nodes as $i => $node) {
    $vars = $base_vars;
    $vars['node'] = $node;
    $vars['count'] = $i;
    $vars['stripe'] = $i % 2 ? 'even' : 'odd';
    foreach ($view->field as $id => $field) {
      $name = $field_names[$id];
      $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
      if (isset($field['label'])) {
        $vars[$name . '_label'] = $field['label'];
      }
    }
    $items[] = _phptemplate_callback('views-list-media', $vars);
  }
  if ($items) {
    return theme('item_list', $items);
  }
}

code of my views-list-media.tpl.php

<div class="view-label view-field-title">
  <?php print $title_label ?>
</div>
<div class="view-field view-data-title">
  <?php print $title?>
</div>

print $title will generate the url and everything,, how can we add that "/a" at the end of the generated link

thanks in advance

Comments

blooksllc’s picture

I am also looking for a way to do this.

blooksllc’s picture

After a lot of searching, I decided to fix my problem for this using cck computed fields and pathauto:

I have a cck computed field (computed field is a separate add-on module for cck) which I call "link_to", it draws on the "display_name" field I set up in cck:

$node_field[0]['value'] = "<a href=\"/NODE_TYPE/".str_replace("+","-",urlencode(trim($node->field_display_name[0]['value'])))."\">".$node->field_display_name[0]['value']."</a>";

Once you enable this you have to edit then save all modules, and you also have to set the field display as true (then disable the field using contemplate).

And a corresponding rule in the pathauto module to set all NODE_TYPE urls to:

NODE_TYPE/[field_display_name-raw]

pathauto will automatically edit all of the needed causes if you check the "Bulk generate aliases for nodes that are not aliased" option, which might also force calculation of your nodes above (I didn't check so I don't know)

Then in views, I simply include "link_to" and the linking is done the way I want it automatically.

I am planning to activate the global redirect module as well to eliminate the node/xxxx path (SEO and user confusion reasons).

I am a bit concerned about the overhead of this method on scaling, but for now it works.

NB: you'll need to replace NODE_TYPE with whatever you are using.

Hope it helps,
Ted

blooksllc’s picture

I needed an easy way to regenerate, so I wrote this: http://drupal.org/node/195013#comment-854212

sun’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.