How can I output aliases in a print function, so I can render links using aliases instead of nid? I have a theme using a views tpl file that is making it impossible for a View to link to node content using the node’s aliases' that i’ve set up. For example it is linking to the default node/36 instead of projects/projectname.

the view contains a grid of ‘thumbnail like content’ wherein each image links to it’s corresponding node. the views template file is renderering links as shown below:

&lt;a style=" background-image: url('&lt;?php print $thumbnail;?&gt;'); " 
class="w-inline-block portfolio-photo portfolio-1" 
href="&lt;?php print drupal_get_path_alias('node/').$row-&gt;nid;?&gt;"&gt;


It’s hardcoding /node/ as a directory and use the function $row->nid

Is there an alias equivalent to nid? Instead of node/36 it the url should be project/projectname

To rewrite the above code using pseudo code it would be…

&lt;a style=" background-image: url('&lt;?php print $thumbnail;?&gt;');"
class="w-inline-block portfolio-photo portfolio-1" 
href="&lt;?php print drupal_get_path_alias(‘projects/‘).$row-&gt;alias;?&gt;”&gt;
You should use the l() function:


  Formats an internal or external URL link as an HTML anchor tag.
  
  This function correctly handles aliased paths and adds an 'active'
  class attribute to links that point to the current page (for theming),
  so all internal links output by modules should be generated by this
  function if possible.


So:

&lt;?php print l('Link text', 
              'node/' . $row-&gt;nid, 
               array(
                 'attributes' =&gt; array(
                   'class' =&gt; array(
                     'w-inline-block',
                     'portfolio-photo',
                     'portfolio-1')))); ?&gt;


You have to supply classes and any other attributes to the l() function.

Note that the first l() parameter (the 'Link text') can be HTML. For this you have to pass in the options array an element HTML set to TRUE. The above example can be:

&lt;?php print l('&lt;img src="/someimg"&gt;Some text&lt;/img&gt;', 
              'node/' . $row-&gt;nid, 
               array(
                 'attributes' =&gt; array(
                   'class' =&gt; array(
                     'w-inline-block',
                     'portfolio-photo',
                     'portfolio-1')
                   )
                 'html' =&gt; TRUE,
                 )
             ); ?&gt;


Also, as noted by the documentation fragmento above, the l() functions handles the aliases. This is because internally drupal_get_path_alias() function is used.