0

i am using blog entry content type and i am displaying blog entry using content view .But their is no any edit and delete button how to add it while using content.Edit and delete button is working only when we use field view.Any idea how to make edit and delete button working when using content view

1 Answer 1

1

Node Full Content is displayed using node.tpl.php. If you would like to override tpl you can copy node.tpl.php and rename it to node--blog.tpl.php in your theme templates folder. For more information refer Drupal 7 Template Suggestions.

You can add Edit and Delete buttons using below code to the overrided template..

<?php 
   if (drupal_valid_path('node/' . $node->nid . '/edit')) {
     print l('Edit', 'node/' . $node->nid . '/edit'); 
   }
?>
<?php 
   if (drupal_valid_path('node/' . $node->nid . '/delete')) {
     print l('Delete', 'node/' . $node->nid . '/delete');
   }
?>
7
  • Everything is fine but Edit and delete button dipalying for other users also.How to hide edit and delete button for other users. Commented Feb 28, 2014 at 5:16
  • Make sure other users don't have edit / delete permissions in permissions list ...
    – Anil Sagar
    Commented Feb 28, 2014 at 5:21
  • Updated code for checking permissions..
    – Anil Sagar
    Commented Feb 28, 2014 at 5:49
  • function drupal_valid_path Checks a path exists and the current user has access to it.Thank you Anil ..this above code is working very fine as per my requirement.. Commented Feb 28, 2014 at 5:50
  • Welcome to SO. If one of the answers above fixes your issue, you should accept it (click the check mark next to the appropriate answer). That does two things. It lets everyone know your issue has been resolved, and it gives the person that helps you credit for the assist.
    – Anil Sagar
    Commented Feb 28, 2014 at 5:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.