I am trying to add the link to my comments on a node template that I am creating. I have the following.

 <!--- <?php
		
		$title = $node->links['comment_add']['title']; //  Share your thoughts and opinions related to this posting. 
		$URL = $node->links['comment_add']['href'];// comment/reply/59 
	
		
		?>
        <?php l("$title", "$URL", array('absolute' => TRUE));?>

I get nothing returned when the page is rendered.

Can someone help me.

Thanks

Comments

nevets’s picture

Your example starts with <!---, an html comment, which means what ever is in the comment does not display.

Also a side note there is no need to quote $title and $URL when passing them to a function.

ginga8’s picture

Should have cleaned up my code a little before I sent it. I was in a rush

 <?php
		
		$title = $node->links['comment_add']['title'];
		$URL = $node->links['comment_add']['href'];
	
		
		?>
       
        <?php l($title, $URL, array('absolute' => TRUE));?>

This the code and it is still not displaying anything

nevets’s picture

Try adding

<pre>
<?php print print_r($node, TRUE); ?>
</pre>

at the end of your node template file to see what node actually contains.

ginga8’s picture

I did what you suggest and these are available

 [links] => Array
        (
            [comment_add] => Array
                (
                    [title] => Add new comment
                    [href] => comment/reply/59
                    [attributes] => Array
                        (
                            [title] => Share your thoughts and opinions related to this posting.
                        )
nevets’s picture

This

<?php l($title, $URL, array('absolute' => TRUE));?>

should be

<?php print l($title, $URL, array('absolute' => TRUE));?>

(notice the print statement)

ginga8’s picture

I can't believe the amount of time I spent trying to figure that out.

Sometimes it is the simplest things you overlook

Thanks so much, it is working now.

ginga8’s picture

This is the link that I am now outputting

<?php print $node->comment ?> Comments |  <?php print l($title, $URL, array('absolute' => TRUE,'attributes' => array('alt' => $node->links['comment_add']['attributes']['title'] ), 'fragment' => $node->links['comment_add']['fragment'] ));?>

Why would it only be available when I am logged in. when I am not logged into the website, the link disappears.

nevets’s picture

That would suggest you have not granted people who are not logged in permission to post comments.