Hey there!
I've been using zenphoto for quite some time now, and I'm very satisfied with it, but there's one thing that would make it even better: a message that prints out "No description" in case a description for an image doesn't exist! I suppose this shouldn't be very difficult to do in the theme itself for those with better knowledge in PHP than me, and that's why I'm humbly asking if someone could help me out. Anyone?
Comments
It's best to keep it blank in the database; otherwise there's no way to actually know if there actually is a description or not.
`<?php if (getImageDesc() == null) echo ""; else echo getImageDesc(); ?>`
Have a nice weekend.
`
<?php<br />
if (getAlbumDesc() != null) {
echo '
}
?>
`
(for image descriptions, swap `getAlbumDesc` for `getImageDesc`)
When using the following code it shows 'No description added yet!' as it should but I can no longer edit the description using the in-built AJAX functions.
`<?php if (getImageDesc() == null) echo "No description added yet!"; else echo printImageDesc(true); ?>`
However, once a description has been added by myself via the main admin section I can still edit it as normal on-the-fly.
Does anyone know how to make it so that I can still edit the description while viewing the image by clicking on the 'No description added yet!' as per the above code?
Please help as I really want to show when there is no description but still require the function to be able to edit it using AJAX if thats clear...
Thanks, CR
A better solution to your problem would be to use phpMyAdmin to insert 'No Description' into any record which currently has an empty description.
Failing this, how hard would it be to add the 'No description' text to the AJAX code so that when it says 'Click to add a description...' it could be 'No description, click to add on...' but only the 'No description' part of the sentance is shown to the public - the remainder to the admin when they are logged in....
CR
I would like it so that I can click on the 'No description' text and edit it to actually add one instead of having to go into the main admin section, find the image with no description, then add one frm there.
So, to recap - when the above code has been added I cannot use the edit on the fly AJAX functions as I could before (unless a comment is already in place, then I can click it to edit as normal).
I hope you see what I mean...
CR
As you can see, my code either allows me to show the comment (if one exists, as well as edit it using AJAX that is tied into the `printImageDesc(true);` command) or show 'No description!' (if there isn't a description for that image). However, it does not allow me to click (and edit) this 'No description' text to add my description using AJAX as it has skipped `printImageDesc(true);` which in turn ties in with the AJAX on-the-fly editing functions...
To get your code working with what I have already do I use something like this:
`<?php if (getImageDesc() == null) OR zp_loggedin()) echo "No description added yet!"; else echo printImageDesc(true); ?>`?
or
`<?php if (getImageDesc() == null) OR zp_loggedin()) { echo "No description added yet!"; else echo printImageDesc(true); } ?>`?
I don't understand why checking to see if I (as the Admin) is logged-in using `zp_loggedin()` will allow me to use the AJAX edit-on-the-fly functions of `printImageDesc(true);`.
Am I missing something....
Thanks
Hacking core files is of course not recommend regarding updates.
Here again my example modified:
`<?php if (getImageDesc() == null AND zp_loggedin()) echo printImageDesc(true); else echo "No description added yet!"; ?>`
Not really different from the standard way that can be achieve by just using `printimagedesc(true)`... I still can't follow what the issue with that is.
Ok, using `printimagedesc(true)` as per the default settings within any theme will as I am sure you know, display nothing to my visitors if a comment has not been added. However, if one has then it will be shown. The other thing this command does is allow the main Admin to use the edit-as-you-go AJAX functions to simply click the text `Click to add a description...` that is only shown while logged in as said Admin.
Now, what I wanted to do was rather than show nothing to my visitors when there is no description; I wanted to show the words, 'No description added yet!' - the code I have does this as follows:
`<?php if (getImageDesc() == null) echo "No description added yet!"; else echo printImageDesc(true); ?>`
This brings us to the point I am at now where I would also still like to be able to use the edit-as-you-go AJAX functions when the above `No description added yet!` text is being shown but as the code stands at the moment the only time I can use these edit-while-you-browse functions is to edit a comment but not add one.
Other than giving you access to my gallery or you making the code changes yourself I cannot explain things any clearer than that sorry.
Anyway, I really hope you can help me.
Thanks again,
CR
Anyway I gave you the functions to solve that... This should do what you want:
`
<?php
if (getImageDesc() == null) {
echo "No description added yet!"
printImageDesc(true);
} else {
printImageDesc(true);
}
?>
`
`Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\*******\Apache2\htdocs\Digital-Photography\themes\Corvus_Corax\image.php on line 107`.
Although after having a play with what you did provide I now have it working. I ended up using the following code:
ALBUM.PHP
`<?php if (getAlbumDesc() == null) echo printAlbumDesc(true) . 'This album does not have a description yet!'; else printAlbumDesc(true); ?>`
IMAGE.PHP
`<?php if (getImageDesc() == null) echo printImageDesc(true) . 'This image does not have a description yet!'; else printImageDesc(true); ?>`
Now when visiting either `album.php`/`image.php` when not logged-in I see 'This album does not have a description yet!' and 'This image does not have a description yet!'. However, if a description is already in place then it is shown as expected
Also when logged-in as the main Admin and visiting either `album.php`/`image.php` I see:
'Click to add a description...
This album does not have a description yet!'
or
'Click to add a description...
This image does not have a description yet!'
Needless to say, all edit-as-you-go AJAX functions now work as they did but with the added descriptive text just how I wanted it
However, one final thing, it would be fab to be able to have it displayed the other way round or even in-line like so:
'This image does not have a description yet!
Click to add a description...'
'This image does not have a description yet! Click to add a description...'
As before, the 'Click to add a description...' sections are only shown to the main Admin anyway but it would just look cleaner. Any ideas?
Thank you so far,
CR
"However, one final thing, it would be fab to be able to have it displayed the other way round or even in-line like so:
'This image does not have a description yet!
Click to add a description...'
'This image does not have a description yet! Click to add a description...'
As before, the 'Click to add a description...' sections are only shown to the main Admin anyway but it would just look cleaner. Any ideas?"
Thanks,
CR
How can I achieve this in the latest version?
I got rid of these lines in template-functions.php
if ( $messageIfEmpty === true ) {
$messageIfEmpty = gettext('(No description...)');
}
but this way the description displays (...) unless I change all of them manually.
If you want this for when you are logged in, it would become a problem for the front-end editing capability.