Author Topic: Hide download button based on permissions using templates?  (Read 9174 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Hide download button based on permissions using templates?
« on: September 28, 2002, 05:43:21 PM »
I know that if the user doesn't have permission to download, a grayed out download button is displayed.  I would like to conditionally remove the download button if the user doesn't have permission as this would allow me to also remove a table cell that holds it.

I also know that we can use {if XXsomeVariable} and {endif XXsomeVariable} to do this with database elements and I do this for some things.

Is there any way to do this for the download button?

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Hide download button based on permissions using templates?
« Reply #1 on: September 28, 2002, 06:15:11 PM »
Easiest way is to replace the images download_off.gif with a white or transparent gif.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Yep
« Reply #2 on: September 28, 2002, 07:42:44 PM »
Yeah I know.  That's what I'm already doing.  I just wanted to know if it was possible to do it directly in the templates.

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Hide download button based on permissions using templates?
« Reply #3 on: September 29, 2002, 10:15:18 AM »
If you are using version 1.7, try:
Code: [Select]
{if allow_download}
  {download_button}
{endif allow_download}

Greets Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Thanks
« Reply #4 on: September 29, 2002, 03:55:15 PM »
Thanks Jan.  I'm using 1.7 and your suggestion comes close to doing what I need.  In my details template I have:
Code: [Select]

{if allow_download}
<td width="70" height="20" align="center">{download_button}</td>
{endif allow_download}


But this produces html output of:
Code: [Select]

<td width="70" height="20" align="center"></td>


Usually in the templates if-endif also excludes the html.  I guess this is only true for database fields as this is what can be reproduced with
Code: [Select]
{if image_description}

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Hide download button based on permissions using templates?
« Reply #5 on: September 29, 2002, 04:07:24 PM »
Strange, this should work like you want it. All html-code should be removed between the if-endif tags. I tested it, for me it works correctly.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Of course
« Reply #6 on: September 29, 2002, 04:23:47 PM »
Duh!  My mistake.  I was looking in the wrong place.  It works!

Question:  Is there any support for "else"?  Something like the following?
Code: [Select]
{if allow_download}
{else}
{endif allow_download}

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Hide download button based on permissions using templates?
« Reply #7 on: September 29, 2002, 04:32:05 PM »
No, sorry.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search