Adding more attributes like title, description, etc but without using customfields.

nonamer

Joined: 2007-03-28
Posts: 63
Posted: Tue, 2012-08-28 18:30

I want to add several new attributes, but I don't want them on the customfield module because it involves extra page, along with extra clicks. It would be much cleaner if those extra fields were included when creating or editing an album. I want them in the itemaddalbum.tpl and itemedititem.tpl

I followed all the steps and I'm pretty confident I didn't miss anything on this thread http://gallery.menalto.com/node/77479

but I don't understand the last two posts about schema updates. How can I do a schema update exactly? I sent a message to the poster, but I haven't heard anything back for 3 days. Can someone tell me how to get this to work, because I know the author of that post did say it worked once he knew about the schema.

thanks!!!

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Tue, 2012-08-28 19:11

Possible but you are getting into advanced customisation and messing with the schema is probably as advanced as you can get.

In your shoes, I'll create a new module and handle the attributes as plugin parameters ("setPluginParameter" and "getPluginParameter") of that module.

You can do this from the ".inc" file and then pass on to the ".tpl" files for display.

The details will depend on your specific needs.

You can of course also study the schema and figure out how it all hangs together but even then, it is best to manipulate it through a bespoke module.

So either way, you will need to write a module to do what you want.
--
dakanji.com

 
nonamer

Joined: 2007-03-28
Posts: 63
Posted: Tue, 2012-08-28 19:50
Dayo wrote:
Possible but you are getting into advanced customisation and messing with the schema is probably as advanced as you can get.

In your shoes, I'll create a new module and handle the attributes as plugin parameters ("setPluginParameter" and "getPluginParameter") of that module.

You can do this from the ".inc" file and then pass on to the ".tpl" files for display.

The details will depend on your specific needs.

You can of course also study the schema and figure out how it all hangs together but even then, it is best to manipulate it through a bespoke module.

So either way, you will need to write a module to do what you want.
--
dakanji.com

making a module is really above my abilities.

so how could I copy the customfielditemedit.tpl into the itemedititem.tpl and be able to hit submit for it to make all those changes on the same page. I just wish someone could better explain that second to last post in that thread.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2012-08-28 19:58

it would be far easier to use custom fields module and fetch them for display in your theme.inc

-s
All New jQuery Minislideshow for G2/G3

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Tue, 2012-08-28 20:16

The second to last post in that thread deals with the detailed inner workings of G2.

BTW, making a module is not that of a big deal but while what you want is definitely doable, I'll suggest you stick with using the existing custom fields module functionality as it is and accept the extra clicks.

--
dakanji.com

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2012-08-28 20:34

just yesterday while making the new shadowbox theme I needed to add new variables to each item in album view.
so in gallery2/themes/my theme/theme.inc function showAlbumPage
you let gallery load all the common template data, then add yours by iterating through the items and adding my variables:

        /* Add resizeId for shadowbox urls */
        $i = 0;
        foreach ($theme['children'] as $child) {
            if ($child['entityType'] == 'GalleryPhotoItem') {
                list($ret, $id) = $this->getBestImageId($child['id']);
                if ($ret) {
                    return array($ret, null);
                }
                $theme['children'][$i]['resizeId'] = $id;
            } else {
                $theme['children'][$i]['resizeId'] = $child['id'];
            }
            $i++;
        }

so now each child photo item has a resizeId which is now available in album.tpl

same concept to add your custom fields:

        GalleryCoreApi::requireOnce('modules/customfield/classes/CustomFieldHelper.class');
        list($ret, $items) = GalleryCoreApi::loadEntitiesById($childIds, 'GalleryItem');
        if ($ret) {
            return array($ret, null);
        }
        list($ret, $tmp, $param, $isContainerSettings) = CustomFieldHelper::fetchFieldValues($items, null, 'photo');
        if ($ret) {
            return array($ret, null);
        }
        $i = 0;
        foreach ($theme['children'] as $child) {
            $theme['children'][$i]['my_cool_field_value'] = $tmp[$child['id']]['my_cool_field_value'];
            $theme['children'][$i]['my_other_cool_field_value'] = $tmp[$child['id']]['my_other_cool_field_value'];
            $i++;
        }

now each child item would have my_cool_field_value and my_other_cool_field_value

-s
All New jQuery Minislideshow for G2/G3

 
nonamer

Joined: 2007-03-28
Posts: 63
Posted: Tue, 2012-08-28 22:00

sorry suprsider. you lost me on what you posted.