[support] Change home page from story to page?

sander-martijn sander at sander-martijn.com
Tue Aug 21 18:48:47 UTC 2007


My solution for now was to change node.tpl.php to have this at the top:
<?php
  global $user;
  $approved_roles = array('superuser', 'editor'); 
?>

and in the header area:
<?php if (is_array($user->roles)) {
  if (count(array_intersect($user->roles, $approved_roles)) > 0){ ?>
      <h2><a href="<?php print $node_url ?>" title="<?php print $title 
?>"><?php print $title ?></a></h2>
<?php }else{ ?>
      <h2><?php print $title ?></h2>
<?php }} ?>

Thanks to the help on this list and the info on this page: 
http://drupal.org/node/104444

Now if you're not an admin it doesn't link to the page, but if you are 
it does so you can edit it.  The only concern I really have about this 
solution is maintenance - right now there are only the above listed 
roles for admin editing.  However if we add "manager", "content 
producer" etc, then a change has to be made to node.tpl.php every time 
that happens.  That is of course not ideal for a single use template 
like this and would be completely unworkable for a reusable template. 

Anyone know of a way to query whether the user has edit rights on the 
node (no matter what their role) instead of whether they're in a 
particular role?  Then I could rewrite this in a way that is more 
maintainable.

thanks
.sander


sander-martijn wrote:
> I'm using node.tpl.php to rewrite the content like this:
> <div>
>     <h2><?php print $title ?></h2>
>     <div class="content"><?php print $content ?></div>
> </div>
>
> So that I don't have the header link bc i don't want the content to 
> show anywhere other than the home page.  Thanks everyone for giving me 
> several different options to try.  At the moment, for my needs it 
> seems like the best option to get what i need would be to change 
> node.tpl.php so that it links the title like normal if you're an 
> admin.  Furthermore I should probably only retheme stories until i get 
> a better handle on the different options.
>
>
> Metzler, David wrote:
>> Last I checked, node Title was a required field, and by default, 
>> the node title on a home page displays with a link to that piece of 
>> content. So how are you suppressing them for the two paragraphs.  Are 
>> you using panels?  Are you supressing the the titles via custom tpl's 
>> for specific node types (e.g. story.tpl)? Are these blocks with 
>> custom text?  Have you customized node.tpl, story.tpl or another .tpl 
>> file to remove titles?
>>  
>> As one person has suggested, adding the edit link at the theming 
>> layer with tests on which "role" a user is in, is one way to add 
>> specific links to editing a node on the page. Could you include more 
>> info about how your paragraphs are constructed?
>>
>> Dave
>>  
>>  
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20070821/da5e7dd2/attachment-0001.htm 


More information about the support mailing list