One of my content types opens in a colorbox node but I need an edit link and flags to appear for certain roles. I'm not using panels for this content type and I'm not using Display Suite either.

Blocks don't get displayed in a colorbox node so I'm wondering what's the easiest and most efficient way to add these links.

Php filter is fine to use.



You could use Views, create a block view.

Under advanced, add relationship of flags of the node and check mark require relationship.

Add flag link and edit link as fields.

Add Contextual filter of nid and select provide default value, then select get ID value from url. (preview will go blank, which is normal here)

Place view block on your node.

Php filter is fine to use.

This is very risky, see: What are the downsides of using PHP Filter code in blocks, nodes, views-args, etc?, if you want to use php, create a template file for your node, block, or view.

Therefore, another option is to create a template file for your content type.

node--[type-name].tpl.php and do php code there.

Ex: node--article.tpl.php

In your template file put

<div class="myedit">
  <?php print '<a href="/node/' . $node->nid . '/edit"> edit </a>'; ?>

<div class="myflag">
  <?php print flag_create_link('FLAGNAME', $node->nid); ?>

<?php print render($content['title']); ?>
<?php print render($content['body']); ?>
<?php print render($content['field_name']); ?>

and so on, you print all the fields you have.

Remember to flush/clear the cache to see changes.

  • The block doesn't get displayed inside Colorbox Node though. As for the php, because this is my own project, I find it easier to develop using the php filter, keep a list, and then turn it all into proper code at the end if I'm happy with the result. Jul 25 '16 at 2:50
  • @NiallMurphy I added some code for the template file.
    – No Sssweat
    Jul 25 '16 at 3:09
  • @NiallMurphy how did it go? you got it to work? If yes, don't forget to accept my answer by clicking the checkmark ✅ as per What should I do when someone answers my question?
    – No Sssweat
    Jul 25 '16 at 13:39
  • 1
    Yeah I got it working thanks! I always forget the checkmark and click the ▲. Jul 25 '16 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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