CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Using drupal permissions in my theme
Pages: [1]

Author Topic: Using drupal permissions in my theme  (Read 2384 times)

adshill

  • I post occasionally
  • **
  • Posts: 96
  • Karma: 8
Using drupal permissions in my theme
September 08, 2009, 01:08:09 pm
I'm trying to utilise drupal permissions in my theme. I found a snippet in a past post by lobo:

http://forum.civicrm.org/index.php/topic,5854.msg26574/topicseen.html#msg26574

Code: [Select]
{if user_access( 'show remove link' )}
{/if}

Which doesn't seem to work as such - it just displays to everyone. Can anyone help with the actual code I need to display something in my theme based on the drupal permission, or worse but still useful, on drupal role?

Thanks a lot!

Adam

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Using drupal permissions in my theme
September 17, 2009, 06:21:10 am
In what file exactly do you want to use this code? If it's part of your Drupal theme, meaning the page.tpl.php in your Drupal theme directory, then the code would look more like:

Code: [Select]
<?php if user_access('show remove link'): ?>
Here is code to be shown
<?php endif; ?>
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

adshill

  • I post occasionally
  • **
  • Posts: 96
  • Karma: 8
Re: Using drupal permissions in my theme
September 24, 2009, 05:11:07 am
Hi there,

No this would be in my CiviCRM theme. In drupal its clear, but I want to provide some icons on the CiviCRM home screen, but I need control over who will see them or not. I could try with drupal code in a Civi theme but I'm presuming this won't work.

Thanks,

Adam

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Using drupal permissions in my theme
September 24, 2009, 10:22:59 am

You can execute php functions within Smarty. Check the Smarty manual for details (http://smarty.net/manual/en)

We dont use it a lot, so cant give lots of example, but here is one snippet:

Code: [Select]
{if $smarty.get.sessionReset}
{$session->reset($smarty.get.sessionReset)}
{/if}

the session variable is exposed to smarty

you should be able to do

Code: [Select]
{if user_access('show civicrm image')}
// add image href and title here
{/if}

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Using drupal permissions in my theme

This forum was archived on 2017-11-26.