CustomField for logged in viewers only.

lnxusr

Joined: 2009-09-06
Posts: 5
Posted: Mon, 2009-09-07 06:15

I'm trying to make the fields from the CustomFields module viewable only by logged in viewers. I've tried wrapping the entire {if !empty($block.customfield.LoadCustomFields.fields)} if statement in the CustomFields.tpl file in an {if $user.isRegisteredUser} statement, but that didn't do anything. In fact if I delete the entire file, the thing still shows the field - even after clearing the template cache.

I'm working on a local server, so no link for that. PHP info is rather long, but it's version 5.2.6 and Gallery is working fine.

G2/system information:

Gallery URL = http://vmserver/gallery2/main.php
Gallery version = 2.3 core 1.3.0
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
PHP version = 5.2.6-3ubuntu4.2 apache2handler
Webserver = Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.2 with Suhosin-Patch mod_scgi/1.12
Database = mysqli 5.1.31-1ubuntu2, lock.system=flock
Toolkits = ArchiveUpload, Exif, Ffmpeg, ImageMagick
Acceleration = none, none
Operating system = Linux vmserver 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:45:36 UTC 2009 x86_64
Default theme = matrix
gettext = enabled
Locale = en_US
Browser = Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.13) Gecko/2009080315 Ubuntu/9.04 (jaunty) Firefox/3.0.13
Rows in GalleryAccessMap table = 12
Rows in GalleryAccessSubscriberMap table = 3
Rows in GalleryUser table = 3
Rows in GalleryItem table = 3
Rows in GalleryAlbumItem table = 1
Rows in GalleryCacheMap table = 0

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 17308
Posted: Mon, 2009-09-07 07:29

I eddited /modules/customfields/templates/blocks/CustomFields.tpl
Added:
{if $user.isRegisteredUser}
to the top of the file and
{/if} to the bottom. Seems to work for me.

See: http://www.langleycom.com/gallery2/main.php
note you can't see the custom field at the bottom of the album page.
Now login: fred/fred
You will now see the custom field displayed.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

Login or register to post comments
lnxusr

Joined: 2009-09-06
Posts: 5
Posted: Mon, 2009-09-07 10:56
floridave wrote:
I eddited /modules/customfields/templates/blocks/CustomFields.tpl
Added:
{if $user.isRegisteredUser}
to the top of the file and
{/if} to the bottom. Seems to work for me.

See: http://www.langleycom.com/gallery2/main.php
note you can't see the custom field at the bottom of the album page.
Now login: fred/fred
You will now see the custom field displayed.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

Thanks for the quick reply Dave,

That sort of works. My original mod above worked as well, but the custom field shows up in the summary under the thumbnail for guest viewers regardless. That's why I thought it wasn't working and why, when I deleted the CustomField.tpl file, it was still showing up. Evidently CustomField.tpl is only for the detail view. What I need to know is where the field is being displayed in the summary so I can wrap that in an if statement as well.

Johnny..

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 17308
Posted: Mon, 2009-09-07 15:51

I can't remember how the custom fields are shown under the thumbs. I have not used custom fields for years.
try to see if it show up as a summary:
edit modules/core/templates/blocks/ItemInfo.tpl

  <div class="summary-{$name} summary">
    {$summary}
  </div>

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Login or register to post comments
lnxusr

Joined: 2009-09-06
Posts: 5
Posted: Tue, 2009-09-08 07:03

Thanks Dave,

Making the following changes (bold) in the last if statement (line 40) did the trick.

  {if !empty($showSummaries)}
    {if $user.isRegisteredUser}
      {foreach from=$item.itemSummaries key=name item=summary}
      <div class="summary-{$name} summary">
        <h6>{$summary}</h6>
      </div>
      {/foreach}
    {/if}
  {/if}
Login or register to post comments