I need to write a very simple piece of PHP code.
All I need is in a page-content_type.tpl.php in Drupal 6 add a simple if command that only calls the tabs variable IF the user is the author of the node.

I think it should look something like this:

            <?php if ($tabs): ?>
              <div class="tabs"><?php print $tabs; ?></div>
            <?php endif; ?>
<?php endif; ?>

I'm hoping I can use $classes>node_by_viewer to achieve this.

Could anyone tell me if I'm going to bang my head against a wall all evening, or if this is actually possible, please?


nevets’s picture

The tabs are only shown if the person viewing the content has access to one of the other tabs soI have to wonder what/who you are trying to block access to.

Manamarak’s picture

Thank you for your comment.
In this particular case, it is a module that is only allowing me the choice of either
-Users can edit all (types of nodes created by module)
-Users can edit only own (types of node created by module)
-Users cannot edit.

But I have one content type created by this module which is shared and everyone must be able to edit it, and another which only the author must be able to edit.

I would like to - as a quick workaround until I can fix the problem properly - find a way of at least stopping users seeing that they have access to editing other people's private nodes.

WorldFallz’s picture

Simply hiding the tabs via a template file is a bad way to approach this-- it won't actually prevent the path from being accessed so anyone familiar with the paths on your site will be able to easily circumvent it.

That said, the page.tpl.php file should have the $node variable which means you can check the author of a node using $node->uid. However, you should really do this properly either with a module like content_access or with hook_menu_alter.

Manamarak’s picture

Thank you, WorldFallz. I realise it is quick and dirty. I think I'm leaning towards an even worse solution - hiding the links via CSS.

I know it is not perfect, but I'm not worried so much about malicious behaviour as I am about ineptitude and a site steering people in the wrong direction.

In the longer term, I'm starting looking at getting someone with actual knowledge of coding to maintain the site. Suggestions of someone on an hourly rate welcome.

Manamarak’s picture