Add link to my module output I have many field for my custom module.

And output:

    if($slides-&gt;rowCount() &gt; 0 ){
        $output .= '&lt;ul id="head_slider" class="clearfix"&gt;';
        foreach($slides as $sld):
            $nd = node_load($sld-&gt;nid);
            if(count($nd-&gt;field_simage) &gt;  0){
                $img_url = image_style_url('img_960x378',$nd-&gt;field_simage['und'][0]['uri']);
            }
            $output .= '&lt;li&gt;&lt;img src="'.$img_url.'" alt="'.$sld-&gt;title.'" /&gt;&lt;/li&gt;';
        endforeach;
        $output .= '&lt;/ul&gt;';
    }


    return $output;
}


Content type has url field. It's name field_surl When users insert a link to this field, must wrap this link to my output.

I tried this but not working:

$output .= '&lt;li&gt;&lt;a href="'.$field_surl.'"&gt;&lt;img src="'.$img_url.'" alt="'.$sld-&gt;title.'" /&gt;&lt;/a&gt;&lt;/li&gt;';


Result of this output:

&lt;a href='field_surl'&gt;...&lt;/a&gt;


How can I fix it?
With the few things I know about your field field_surl and about the way you tried to solve it, I might purpose this simple answer, sorry if it sounds obvious :

You wrote :

$output .= '&lt;li&gt;&lt;a href="'.$field_surl.'"&gt;&lt;img src="'.$img_url.'" alt="'.$sld-&gt;title.'" /&gt;&lt;/a&gt;&lt;/li&gt;';


Where did you initialize your $field_surl variable ? At least, assuming $field_surl is loaded within the same node, try :

$output .= '&lt;li&gt;&lt;a href="'.$nd-&gt;field_surl.'"&gt;&lt;img src="'.$img_url.'" alt="'.$sld-&gt;title.'" /&gt;&lt;/a&gt;&lt;/li&gt;';


Or even better, as suggested in @Brandon comment, use url() function :

$options = array('absolute'=&gt;TRUE); //i.e, or set whatever options you need for your url
$my_url = url($nd-&gt;field_surl, $options);
$output .= '&lt;li&gt;&lt;a href="'.$my_url.'"&gt;&lt;img src="'.$img_url.'" alt="'.$sld-&gt;title.'" /&gt;&lt;/a&gt;&lt;/li&gt;';