add custom field that's only shown to those logged in?

neubeedoo

Joined: 2005-10-08
Posts: 14
Posted: Wed, 2007-01-03 00:57

I want to add a custom field that will only display to someone who is loged in.
For example, when viewing a photo I have a custom field for credits that shows to all who can view. I want an additional custom field "source" that will only show to those who are logged in - not to the general public.

How and what do I need to add?
-I am comfortable altering php with good instructions, but am not at all well versed in php coding from scratch - thanks!

- k

The following information is required to get an answer:
Get this information from the PHP diagnostic (in the configuration wizard).
Gallery URL (optional but very useful): (not yet public)
Gallery version: 1.5.4
Apache version: Apache1.3.33
PHP version (don't just say PHP 4, please):4.3.11
Graphics Toolkit: ImageMagick
Operating system: linux
Web browser/version (if applicable):

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2007-01-03 02:46

in view_photo.php
find

<!-- Custom Fields -->
<?php
displayPhotoFields($index, $extra_fields, true, in_array('EXIF', $extra_fields), $full);
?>

and change to

<!-- Custom Fields -->
<?php
if ($gallery->user->isLoggedIn()) {
displayPhotoFields($index, $extra_fields, true, in_array('EXIF', $extra_fields), $full);
}
?>

Dave
_____________________________________________
Blog & G2 || floridave @ Gallery Team || G2 Theme Contest: +$3k in Prizes!

 
neubeedoo

Joined: 2005-10-08
Posts: 14
Posted: Wed, 2007-01-03 03:08

Thanks Dave,
but Won't that make ALL my customfields viewable only by logging in?

I need to isolate only one particular customfield (one called "source") to those logged in -
the others (details and donor) should be seen with and without log-in.

thanks!

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2007-01-03 04:42

that is a bunch more work

Dave
_____________________________________________
Blog & G2 || floridave @ Gallery Team || G2 Theme Contest: +$3k in Prizes!

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2007-01-03 05:31

What I would do is look for

        foreach ($fields as $key => $value) {
            $customFieldsTable->addElement(array('content' => $key));
            $customFieldsTable->addElement(array('content' => ':'));
            $customFieldsTable->addElement(array('content' => $value));
        }

in /lib/content.php
Then do a bunch of if/else statments for the fields you want to show.

Dave
_____________________________________________
Blog & G2 || floridave @ Gallery Team || G2 Theme Contest: +$3k in Prizes!

 
neubeedoo

Joined: 2005-10-08
Posts: 14
Posted: Wed, 2007-01-03 18:48

Thanks - I thought it might come to that - They'll just have to live without for now!
- k

 
lnxusr

Joined: 2009-09-06
Posts: 5
Posted: Sun, 2009-09-06 04:09
floridave wrote:
in view_photo.php
find

<!-- Custom Fields -->
<?php
displayPhotoFields($index, $extra_fields, true, in_array('EXIF', $extra_fields), $full);
?>

and change to

<!-- Custom Fields -->
<?php
if ($gallery->user->isLoggedIn()) {
displayPhotoFields($index, $extra_fields, true, in_array('EXIF', $extra_fields), $full);
}
?>

Dave
_____________________________________________
Blog & G2 || floridave @ Gallery Team || G2 Theme Contest: +$3k in Prizes!

Where would this go now? Gallery doesn't seem to have a view_photo.php anymore.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2009-09-06 06:06
Quote:
Where would this go now? Gallery doesn't seem to have a view_photo.php anymore.

FAQ: What information is required when I ask for help in the forums?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
lnxusr

Joined: 2009-09-06
Posts: 5
Posted: Mon, 2009-09-07 05:15
floridave wrote:
Quote:
Where would this go now? Gallery doesn't seem to have a view_photo.php anymore.

FAQ: What information is required when I ask for help in the forums?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Sorry,

I have the CustomField module installed. What I'm trying to do is get that info to only display to logged in viewers. I've tried wrapping the entire {if !empty($block.customfield.LoadCustomFields.fields0} 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.

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

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2009-09-07 05:58
Quote:
Gallery version = 2.3 core 1.3.0

This is a G1 thread.

Please start a new thread in the G2 customization forums if clearing template cache does not help.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team