How to change link to a node's path in Views conditionally I have what I'm calling a "student blog" section. Students can create a blog either locally (with a Body field), or remotely using a Link. A single conditional_fields value of "blog is hosted" controls what is shown on the add_node_form.

These blog entries are moderated via Workbench Moderation.

Anyways in Views 3.x I want to make a listing of the blog titles, linked to their content. If the content was "local" I want a link to node/NID or the url alias. If the content was "remote url" I want the url to point to the offsite url for the blog post (eg, Blogger.com).

I have created the content type, and a simple views block that lists the node titles .... but I can't get the link(s) to point to the correct locations per entry.

If possible, please submit answers using Views 3.x Core only (not views_php, etc) ... this site has a ton of modules already :P

Images of configuration:

Content Type Fields


Initial Blog Creation Screen


Blog was Local screen


Blog was Remote Url screen


Views Block Output of Node Titles (that should link either local or remote
You could add a blog_url field which you hide in a form alter and  programmatically set when the form is submitted. If the blog is remote, you set it to the value of the link field. If it's local, you set it to the value of the node. You can then use this field in Views (just include the Title field and use 'Link this field' to link it to the value of blog_url). Something along the lines of:

/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&amp;$form, $form_state, $form_id) {
  if ($form_id == 'school_blog_node_form') {
    $form['field_blog_url']['#access'] = FALSE;
    $form['#validate'][] = 'mymodule_validate_school_blog_form';
  }
}

/**
 * Validate handler for school_blog edit form.
 */
function mymodule_validate_school_blog_form($form, &amp;$form_state) {
  if ($form_state['values']['field_blog_is_hosted'] == 'local') {
    $form_state['values']['field_blog_url'] = 'node/' . $form['nid'];
  }
  else {
    $form_state['values']['field_blog_url'] = $form_state['values']['field_blog_remote_url'];
  }
}