Views Output field as a link - Two tokens, use only one of them I have content type which has field_pdf.
I have made view to show content and there is a field which has set: Output field as a link.
In link path settings I have two tokens: [field_pdf][path]. Idea is to link field either straight to PDF (if there is PDF file in node) or to content node.

How to get view to use only [field_pdf] when this field_pdf has content and not use [path] at all?

Now I'm getting double url for example: http://url.com/pdf-file.pdfhttp://url.com/pdf
Modules You Need:

Views
Views PHP

Assuming your content type is having these fields:

The VIEWS Code:
Simply go to admin/structure/views/import and then Import the below mentioned code:
$view = new view();
$view-&gt;name = 'pdf';
$view-&gt;description = '';
$view-&gt;tag = 'default';
$view-&gt;base_table = 'node';
$view-&gt;human_name = 'PDF';
$view-&gt;core = 7;
$view-&gt;api_version = '3.0';
$view-&gt;disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view-&gt;new_display('default', 'Master', 'default');
$handler-&gt;display-&gt;display_options['title'] = 'PDF';
$handler-&gt;display-&gt;display_options['use_more_always'] = FALSE;
$handler-&gt;display-&gt;display_options['access']['type'] = 'perm';
$handler-&gt;display-&gt;display_options['cache']['type'] = 'none';
$handler-&gt;display-&gt;display_options['query']['type'] = 'views_query';
$handler-&gt;display-&gt;display_options['exposed_form']['type'] = 'basic';
$handler-&gt;display-&gt;display_options['pager']['type'] = 'full';
$handler-&gt;display-&gt;display_options['pager']['options']['items_per_page'] = '10';
$handler-&gt;display-&gt;display_options['style_plugin'] = 'default';
$handler-&gt;display-&gt;display_options['row_plugin'] = 'fields';
/* Field: Content: PDF */
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['id'] = 'field_pdf';
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['table'] = 'field_data_field_pdf';
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['field'] = 'field_pdf';
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['label'] = '';
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['exclude'] = TRUE;
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['alter']['make_link'] = TRUE;
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['alter']['path'] = '[field_pdf][path]';
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['element_label_colon'] = FALSE;
/* Field: Global: PHP */
$handler-&gt;display-&gt;display_options['fields']['php']['id'] = 'php';
$handler-&gt;display-&gt;display_options['fields']['php']['table'] = 'views';
$handler-&gt;display-&gt;display_options['fields']['php']['field'] = 'php';
$handler-&gt;display-&gt;display_options['fields']['php']['label'] = '';
$handler-&gt;display-&gt;display_options['fields']['php']['element_label_colon'] = FALSE;
$handler-&gt;display-&gt;display_options['fields']['php']['use_php_setup'] = 0;
$handler-&gt;display-&gt;display_options['fields']['php']['php_output'] = '&lt;?php
if (isset($data-&gt;field_field_pdf[0][\'rendered\'][\'#markup\'])) {
    $pdf_url = $data-&gt;field_field_pdf[0][\'rendered\'][\'#markup\'];
    print $pdf_url;
} else {
    global $base_url;
    $node_url = $base_url . \'/node/\' . $data-&gt;nid;
    print $node_url;
}
?&gt;';
$handler-&gt;display-&gt;display_options['fields']['php']['use_php_click_sortable'] = '0';
$handler-&gt;display-&gt;display_options['fields']['php']['php_click_sortable'] = '';
/* Sort criterion: Content: Post date */
$handler-&gt;display-&gt;display_options['sorts']['created']['id'] = 'created';
$handler-&gt;display-&gt;display_options['sorts']['created']['table'] = 'node';
$handler-&gt;display-&gt;display_options['sorts']['created']['field'] = 'created';
$handler-&gt;display-&gt;display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler-&gt;display-&gt;display_options['filters']['status']['id'] = 'status';
$handler-&gt;display-&gt;display_options['filters']['status']['table'] = 'node';
$handler-&gt;display-&gt;display_options['filters']['status']['field'] = 'status';
$handler-&gt;display-&gt;display_options['filters']['status']['value'] = 1;
$handler-&gt;display-&gt;display_options['filters']['status']['group'] = 1;
$handler-&gt;display-&gt;display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler-&gt;display-&gt;display_options['filters']['type']['id'] = 'type';
$handler-&gt;display-&gt;display_options['filters']['type']['table'] = 'node';
$handler-&gt;display-&gt;display_options['filters']['type']['field'] = 'type';
$handler-&gt;display-&gt;display_options['filters']['type']['value'] = array(
  'pdf' =&gt; 'pdf',
);

/* Display: Page */
$handler = $view-&gt;new_display('page', 'Page', 'page');
$handler-&gt;display-&gt;display_options['path'] = 'pdf';

I'm sure you might be having some dummy content for that content-type, if not then do create couple of ones. Some with values in field_php and some with not!
and Voila! Here is your required output:

Updated Code:
$view = new view();
$view-&gt;name = 'pdf';
$view-&gt;description = '';
$view-&gt;tag = 'default';
$view-&gt;base_table = 'node';
$view-&gt;human_name = 'PDF';
$view-&gt;core = 7;
$view-&gt;api_version = '3.0';
$view-&gt;disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view-&gt;new_display('default', 'Master', 'default');
$handler-&gt;display-&gt;display_options['title'] = 'PDF';
$handler-&gt;display-&gt;display_options['use_more_always'] = FALSE;
$handler-&gt;display-&gt;display_options['access']['type'] = 'perm';
$handler-&gt;display-&gt;display_options['cache']['type'] = 'none';
$handler-&gt;display-&gt;display_options['query']['type'] = 'views_query';
$handler-&gt;display-&gt;display_options['exposed_form']['type'] = 'basic';
$handler-&gt;display-&gt;display_options['pager']['type'] = 'full';
$handler-&gt;display-&gt;display_options['pager']['options']['items_per_page'] = '10';
$handler-&gt;display-&gt;display_options['style_plugin'] = 'default';
$handler-&gt;display-&gt;display_options['row_plugin'] = 'fields';
/* Field: Content: PDF */
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['id'] = 'field_pdf';
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['table'] = 'field_data_field_pdf';
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['field'] = 'field_pdf';
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['label'] = '';
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['exclude'] = TRUE;
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['alter']['make_link'] = TRUE;
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['alter']['path'] = '[field_pdf][path]';
$handler-&gt;display-&gt;display_options['fields']['field_pdf']['element_label_colon'] = FALSE;
/* Field: Global: PHP */
$handler-&gt;display-&gt;display_options['fields']['php']['id'] = 'php';
$handler-&gt;display-&gt;display_options['fields']['php']['table'] = 'views';
$handler-&gt;display-&gt;display_options['fields']['php']['field'] = 'php';
$handler-&gt;display-&gt;display_options['fields']['php']['label'] = '';
$handler-&gt;display-&gt;display_options['fields']['php']['alter']['make_link'] = TRUE;
$handler-&gt;display-&gt;display_options['fields']['php']['alter']['path'] = '[php]';
$handler-&gt;display-&gt;display_options['fields']['php']['alter']['absolute'] = TRUE;
$handler-&gt;display-&gt;display_options['fields']['php']['element_label_colon'] = FALSE;
$handler-&gt;display-&gt;display_options['fields']['php']['use_php_setup'] = 0;
$handler-&gt;display-&gt;display_options['fields']['php']['php_output'] = '&lt;?php
if (isset($data-&gt;field_field_pdf[0][\'rendered\'][\'#markup\'])) {
    $pdf_url = $data-&gt;field_field_pdf[0][\'rendered\'][\'#markup\'];
    print $pdf_url;
} else {
    global $base_url;
    $node_url = $base_url . \'/node/\' . $data-&gt;nid;
    print $node_url;
}
?&gt;';
$handler-&gt;display-&gt;display_options['fields']['php']['use_php_click_sortable'] = '0';
$handler-&gt;display-&gt;display_options['fields']['php']['php_click_sortable'] = '';
/* Sort criterion: Content: Post date */
$handler-&gt;display-&gt;display_options['sorts']['created']['id'] = 'created';
$handler-&gt;display-&gt;display_options['sorts']['created']['table'] = 'node';
$handler-&gt;display-&gt;display_options['sorts']['created']['field'] = 'created';
$handler-&gt;display-&gt;display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler-&gt;display-&gt;display_options['filters']['status']['id'] = 'status';
$handler-&gt;display-&gt;display_options['filters']['status']['table'] = 'node';
$handler-&gt;display-&gt;display_options['filters']['status']['field'] = 'status';
$handler-&gt;display-&gt;display_options['filters']['status']['value'] = 1;
$handler-&gt;display-&gt;display_options['filters']['status']['group'] = 1;
$handler-&gt;display-&gt;display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler-&gt;display-&gt;display_options['filters']['type']['id'] = 'type';
$handler-&gt;display-&gt;display_options['filters']['type']['table'] = 'node';
$handler-&gt;display-&gt;display_options['filters']['type']['field'] = 'type';
$handler-&gt;display-&gt;display_options['filters']['type']['value'] = array(
  'pdf' =&gt; 'pdf',
);

/* Display: Page */
$handler = $view-&gt;new_display('page', 'Page', 'page');
$handler-&gt;display-&gt;display_options['path'] = 'pdf';

Let me know if you need anything else from this.
Cheers!