Pages (2):    1 2
Member
Member
sbillard   23-08-2013, 21:49
#21

You can also get the global parent album from any album by getUrAlbum($album_object)

Member
Member
Papyrus   24-08-2013, 01:23
#22

And with that useful call it's an even easier job. $variable = getUrAlbum($album_object). If $variable = photocards do this. If $variable = photobook do that. Cuts half the work of writing the function out.

Member
Member
sbillard   24-08-2013, 02:20
#23

Except that the function returns an object, so what you need is if ($variable->name = photocards)....

Member
Member
tosca   24-08-2013, 07:01
#24

Thanks everybody for helping.
I've succeeded in what I wanted to do: in the custom data field, I can enter as many name=value separated by a comma, and get them as an array in the program.

The only thing that remains to make it 'perfect' is transforming it into a function so I can use it in any other php page.

Member
Member
tosca   24-08-2013, 07:59
#25

@Papyrus: the purpose of using custom data or code block is precisely to avoid hard-coding. I didn't want either to make references to the album names or their parent.

With my solution, I have nothing to add/modify when I add a new album, or modify one that already exists. I can even add as many new variables as I want too, they will be automatically available in the program.

Administrator
Administrator
acrylian   24-08-2013, 08:28
#26

Good you managed it for your purpose! Many roads lead to Rome :-)

Member
Member
tosca   24-08-2013, 13:08
#27

Yes, once you know how to find your way! ;-)

Member
Member
Papyrus   24-08-2013, 15:31
#28

Well I'm very happy you worked it out. Always nice to see the different ways people tackle issues!

If it does help anyone in the future though, I whipped up my variant of the idea as a foundation. I'm sure many future visitors would appreciate any alternate methods you might be employing spelled out for them if you feel like it, tosca.

http://animepapers.org/software/zenphoto/code-snippets/multiple-layouts-dynamic-modification.html

Probably far from perfect, but if anybody needs a reference it's there with a tiny bit of documentation.

I'll also post here...and see how it comes out:

`

        echo '"'.getImageTitle().'"';

`

Administrator
Administrator
acrylian   24-08-2013, 15:53
#29

@Papyrus: Some quick comments:

  1. $masal = $_zp_current_album->getParent();
    getParent() returns an album object if there is a parent or NULL, so it is quite different to $theDecider;

  2. $theDecider = $_zp_current_album->getTitle();
    You should use the album name here. The title is never unique identifier especially since it changes on multilingual sites per language naturally.

  3. if ($theDecider = 'album-name-1')
    You mean of course == ;-)

Member
Member
tosca   24-08-2013, 17:45
#30

Here is the function I've written, but it is for retrieving custom data, whatever they are; in addition to custom thumbnails dimension, I've already used it to assign specific classes, and it could be used for anything else.

/* ** Récupération du contenu de "Données personnalisées" */ function mnaCustomData($page) { switch ($page) { case('album') : global $_zp_current_album; $custom_data = getAlbumCustomData(); break; case('image') : global $_zp_current_image; $custom_data = getImageCustomData(); break; case('page') : global $_zp_current_zenpage_page; $custom_data = getPageCustomData(); break; case('category') : global $_zp_current_category; $custom_data = getNewsCategoryCustomData(); break; case('news') : global $_zp_current_zenpage_news; $custom_data = getNewsCustomData(); break; } $data_array = explode(",",$custom_data); foreach ($data_array as $one_data) { $label_value = explode("=",$one_data); $custom_data_array[trim($label_value[0])] = trim($label_value[1]); } return $custom_data_array; }

Administrator
Administrator
acrylian   24-08-2013, 18:20
#31

That's actually more or less what I suggested above btw :-) What is $page in your context? Just asking since there is no "category" page.

Member
Member
Papyrus   24-08-2013, 19:14
#32

@acrylian Ah! Thanks for the tips, will help me going forward. I knew that title was a bad thing to call but just couldn't remember off the top of my head what else to use...and it worked so I shrugged it off. Corrections are always appreciated.

@tosca I see, a little different from what I pictured but useful for more than just many levels of image sizing. Looks nice. Thanks for contributing your code snippet too!

Member
Member
tosca   24-08-2013, 21:52
#33

$page allows to choose which custom data you want to get.
It works for album, image, page (as in Zenpage), category news, or news.
Unless I'm mistaken, getCustomData() exists for all these 5 objects.

Pages (2):    1 2
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.