The simpler media website CMS
Hello,
I'm trying to turn on/off a bloc if comments are allowed or not (that is a different question if plugin is activate or not).
I tried this : if (function_exists('printCommentForm')) { if (commentsAllowed() == true) { echo '<div class="bloc-comments">'; echo '<h2>Commentaires</h2>'; printCommentForm(); echo '</div>'; } }
And this
if (function_exists('printCommentForm')) { if (comment_form_postcomment() == true) { echo '<div class="bloc-comments">'; echo '<h2>Commentaires</h2>'; printCommentForm(); echo '</div>'; } }
Both make PHP fail. But I'm sure I'm close to solution if I had a correct understanding of the documentation : https://docs.zenphoto.org/1.5.x/function-comment_form_postcomment.html Any clue ? Thanks !
Comments
comment_form_postcomment()
is an internal function if processing comments is allowed:https://docs.zenphoto.org/1.5.x/function-comment_form_postcomment.html
commentAllowed()
requires a parameter what type of comments (which item type image, album, Zenpage page or news article) you refer to. the parameter refers howecer to the option name and not the plain item name (the doc does not tell this): https://docs.zenphoto.org/1.5.x/function-commentsAllowed.htmlThe best is actually to use the object model like:
if($obj->getCommentsAllowed()) { … }
$obj
is here the object of an item type. For example an a standard themeimage.php
page you can use the global object$_zp_current_image->getCommentsAllowed()
to check for this image. Basic overview about the object model:https://www.zenphoto.org/news/zenphotos-object-model-framework/
Thanks acrylian !