I'm not sure how they are called in the english version; in french, I see them as 'Données personnalisées' in both the album and image page of the admin interface.
What can we put there, and how to format it? Unless I missed something, I didn't find any method to get the information that has been put in this field.
Thanks for your answer.
Comments
I guess that means the formating is free, and I need to decide how to store my own data in there.
Since this means apparently "custom data". That is an all purpose text field and it is up to you what you do with it exactly. You can attach The editor TinyMCE to it and use it like any other content field. You can add and output html or js code but not PHP code. For the latter the codeblocks are meant.
As for the custom data, I tried `print $_zp_current_album->getAlbumCustomData();` but got the following error: `Fatal error: Call to undefined method Album::getAlbumCustomData()`. I am missing something, but what?
2. Well if you didn't call it within album context it naturally doesn't work since the album object is not available (but this you should really know by now as a long time user :-)).
The line before `print $_zp_current_album->getAlbumCustomData();` is `print $_zp_current_album->getDesc();` and it works...
What could be the difference between those two?
http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functiongetAlbumCustomData
`print $_zp_current_album->getCustomData()` would be the class way.
`getDesc` is a class method, its template equivalent would be `getAlbumDesc`: http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functiongetAlbumDesc`
But I've not still found the best way to manage more than one information for some several albums:
- either I use the custom data, but I would like to use an array, in order to get something like "width" => 158, "height" => 108; currently I only succeeded in retrieving one single string, so I need to parse it manually I think
- the other option would be to use the codeblock and assign values to several variables. `$width=158; $height=108;` does seem to work, but the values are lost after the code block has been executed: they're not there anymore in the page template.
Any suggestion to do this, in a manner that could be simply managed with different values for several albums?
You can create arrays out of like "158,108" or "158/108) using the php standard function explode.
Reading your comment it seems you want different image sizes depending on which album is called up.
Having seen how to do this in the past, if you do not need a ton of different sizes, the best way to do so is to create variant themes and use the plugin that allows a different theme assignment per album then call the modified page. Can't remember the plugin name right off, sure someone else can contribute it if yoy can't find it.
1) I'm working on my own theme, that works for all the photographies (about 90% of the gallery)
2) for the remaining pictures files, such as postcards, press-book, graphic work and such, I use the multiple-layouts plugin with a custom album page, and a custom image page
3) I'd rather avoid different custom pages, because of future maintenances; things are too similar from one type of pictures to the other, so I'd rather find some solution using either custom data or code block on specific albums
4) entering a list of numeric values in the custom data doesn't seem very user-friendly / reliable, that's why I'd like to link each value to either a meaningful label (width, height, and such) or use the code block to assign a value to each variable.
@acrylian: I tried to use global variables, but it didn't work. I probably dit it wrong... can I find somewhere an example of codeblock in that manner?
And by the way, I didn't find the way to switch the language in the admin interface: when I choose English in the general options tab, the interface remains in French!
4) I agree but it is the simplest solution probably - especially if you are the only one managing possibly? - without the need of a extra plugin providing extra fields or the like.
Globals and codeblock: We don't have any example I fear. I haven't tried this, it was just a quick idea.
Language: That would mean you don't have an English/US locale on your server. The languages are tied to those available. My live server for example has only English and German, so French would not work (my local MAMP server has them all though). Maybe contact your host if they can set it up. It would just help us if we use the same terms when supporting.
4) the simplest thing for putting the gallery on line is not necessarily also the simplest on the long time.
Yes, I'm the only one managing the gallery, but I'd rather spend as little time as possible tuning code in the future. My main goal is to publish my work on the web, not to manage the gallery. :-)
I'll go on trying some things tomorrow, and will revert to a hard-coded solution if I don't find quickly something more sustainable.
Language: I have no idea what the limits of my hosting service are. And I've recently reinstalled locally a new Linux/Fedora version and didn't take time to set up a new local server; guess I'll do it when my Zenphoto gallery will be public so I have no other option if I want to prepare other modifications!
4) Although My main goal is to publish my work on the web, not to manage the gallery. :-) is a bit related if you self host, isn't it? :-)
The best from hte user point of view would be a plugin providing extra fields for that specific purpose. However that means some work ;-)
Re: language: We have a script to display available locales: https://github.com/zenphoto/Unsupported/tree/master/misc/list_locales
I found out the answer for the language: I needed to deactivate the French otherwise it remains the default. Deactivation of the HTTP_AcceptLanguage was not enough apparently.
That being said, here is another method that would require a touch more work but could accomplish the goal with one function. What you could do is grab the URI and match against a list of album names (likely at the top level, where you split into postcards, photo books, etc.. so it'd automatically apply to sub-albums) grab that album name, set it as a variable, then run a loop that checks the variable and (if x album, then y dimensions) prints that on the page. A bit more work but only one function to maintain.
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.
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.
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:
`
<?php<br />
$masal = $_zp_current_album->getParent();
if (strlen($masal) == 0)
{
$theDecider = $_zp_current_album->getTitle();
} else {
$theMiddleMan = reset($masal);
$theDecider = current($masal);
}
?>
<?php </p>
if ($theDecider = 'album-name-1') {
$iw = 189;
$ih = NULL;
$cw = 909;
$ch = 67;
} elseif($theDecider = 'album-name-2') {
$iw = NULL;
$ih = 989;
$ch = 149;
$cw = 79;
} elseif($theDecider = 'album-name-3') {
$iw = NULL;
$ih = 389;
$ch = 89;
$cw = 67;
} else {
$iw = NULL;
$ih = 85;
$ch = 99;
$cw = 99;
}
?>
echo '
getCustomImage(NULL, $iw, $ih, $cw, $ch, NULL, NULL, true)) . '); ">"'.getImageTitle().'"';`
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 `==` ;-)
`
/*
** 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;
}
`