php code in Codeblocks doesn't work with 1.4.1

vincent3569 Member, Translator
hi

there is something I don't understand with 1.4.1.

with 1.4.0, I wrote the following code in a Codeblocks of a page. It shows a random image of a dynamic album.
This page is selected as homepage of zenpage theme.
-> everything works fine

with 1.4.1, It doesn't works :
-> when I choose Index page (who is my page), random image is not displayed wether I'm connected or not.
-> if I'm connected and if I choose the page in page menu, the random image is well displayed.

`



<?php<br />
global $image;

$image = getRandomImagesAlbum('Portfolio.alb');

makeImageCurrent($image);

if (is_object($image) && $image->exists) {

echo '';

printCustomSizedImage(gettext('Gallery'), null, 350, 350, 350, 350, null , null, 'ombreB');

echo '
';

} ?>



`

can you help me to solve this problem ?
thanks in advance

Comments

  • Sorry, what do you mean by "connected"? What is displayed when the random image does not display?

    BTW, I don't think it is the issue, but you should not be calling the makeImageCurrent() function unless you know the image is valid--That is put it inside your test.
  • vincent3569 Member, Translator
    sorry, I would mean login rather connected.

    nothing is displayed when I am login : the image is placed in the empty space in the page.

    you could see the result here : http://vincent.bourganel.free.fr/zenphoto_t2/
  • vincent3569 Member, Translator
    to see the problem, I uplicate the page.
    'Accueil' page is selected as homepage (called 'Home' in english) -> the image is not shown

    'Test' page is the same as Accueil -> the image is shown
  • I do not really have any idea what is wrong. But some suggestions for finding out.

    in functions-basic up near the beginning make sure that full error reporting is set. `error_reporting(E_ALL | E_STRICT);` if you have PHP5.

    If running with that shows nothing then try instrumenting the getRandomImagesAlbum() function. Do a `var_dump($images);` right after where the $images variable is set to the dynamic album's images. See if the result is the same for both cases.

    Also try with at normal album to see if somehow this is a dynamic album problem.
  • vincent3569 Member, Translator
    - The full error reprting is set, but I don't know where the errors are reported.

    - I add "var_dump($images);" , but the problem is still the same

    - The problem is still the same with a non dynamic album

    another thing :

    I notice that the value of $_zp_gallery_page is not the same between 1.4.0 and 1.4.1
    - with 1.4.1
    when you are on 'home', $_zp_gallery_page = index.php
    when you are on 'test', $_zp_gallery_page = page.php
    - with 1.4.0, $_zp_gallery_page = page.php in the 2 cases.

    maybe there is a lost of context ?
  • The idea behind the var_dump is that you would look at what it shows. Does it show the same thing in both cases?

    As to the errors, you really need to find out where to look--ask your provider. Error reports are critical for debugging issues.

    I doubt that the value of $_zp_gallery_page is the issue, but in anycase, the proper value for the index page should be index.php. Not sure how 1.4.0 got it wrong. The code you showed is not context sensitive to the page.

    Given the problem is the same for dynamic/not dynamic albums the most likely cause is a PHP error somewhere. Id you can't find the error log you can do a step by step debug. Start with simple text in the code block and see if it shows up. Then slowly add things until they fail.
  • vincent3569 Member, Translator
    if you have a look on http://vincent.bourganel.free.fr/zenphoto_t2/index.php?p=pages&title=test, you will the result of var_dump(image).

    on home page, I try with
    -<div id="daily-image" style="float: left;">test</div>
    -and <?php echo 'test' ?>
    in Codeblock 1

    but there is no display

    it seems Codeblock of the page are not displayed in all context...
  • Ok, I have found the problem. This use of pages for the home page leaves a little to be desired. There is a codeblock for the index.php page, so that is what is getting used. The code for the theme pages.php that does the printCodeblock() will need to supply the object to get the codeblock from rather than using the default for the "gallery page".

    Where it has `printCodeblock(1);` It will need to have `printCodeblock(1,$_zp_current_zenpage_page);`

    There are other issues as well--specifically `printCommentForm()` There are no comments on the index page. Fortunately this seems to just do nothing rather than generate a fault. Not sure what else might be wrong as well. But the problem is that the page itself is somewhat out of context.

    [edit] Ratings do fail since the rating plugin is not prepared to deal with the index.php page. We can fix that.
  • vincent3569 Member, Translator
    we progress in resolving the problem ... but it is not yet resolved

    if I put the following code in page.php:
    <? php printCodeblock (1, $ _zp_current_zenpage_page)?>
    The following string is displayed a: 3: {i: 1; s: 6: "test 1"; i: 2; s: 6: "test 2"; i: 3; s: 6: "test 3";}
    "test 1", "test 2", "test 3" is the content of codeblocks 1, 2 and 3.

    This string is displayed as well on the page and the page is the homepage (index.php)
  • vincent3569 Member, Translator
    to be more precise, the behavior is very different between different themes:
    zenpage: the test page, only shows BockCode 1, the index page is blank
    garland: the test page, displays BockCode 1 and 2 and there is no index page
    zpardoise : the string a: 3: {i: 1; s: 6: "test 1"; i: 2; s: 6: "test 2"; i: 3; s: 6: "test 3";} is displayed.
  • acrylian Administrator, Developer
    Not all themes have all codeblock implemented, the Zenpage theme has only no. 1 on Zenpage pages currently.
  • So maybe you should be running version 1.4.1.1?
  • vincent3569 Member, Translator
    I am with 1.4.1.1 (night build 7645).

    Be sure that there is an issue : BlockCodes are not displayed on a page choosen for homepage.
  • You are correct, PHP does not work in the gallery level codeblocks. I have no idea why, though. It appears that the PHP `eval()` function is not recognizing the `<?php` tag.

    But why that happens at the gallery level and not elsewhere is a mystery. Probably should file a ticket on this, but how to fix is not known.
  • vincent3569 Member, Translator
    the only thing I can say to help you is that it worked fine with version 1.4.0.3 [6817].
    You can see the result on my website here http://vincent.bourganel.free.fr/zenphoto/.
    the image is provided by the php code described in my first post and written in BlockCode(1) of my page called Accueil and choosen to be the homepage of my website.

    the only difference I found is that the value of $_zp_gallery_page is not the same between 1.4.0 and 1.4.1 as describe above.

    I have create a ticket http://www.zenphoto.org/trac/ticket/1934
  • Maybe you can give the nighty DEV branch a try. I have been working on this problem of what codeblock to invoke.

    Added some context to the next_news loop so that we can tell that we should be using the news codeblock and not some other.

    Similarly for pages, if we are in page context use the page codeblock.

    There still may be some confusion depending on what a theme does. The priority of use is: news, page, image, album, gallery. It will use the first of these where the context is correct.

    [Note: on 1.4.0 there were no codeblocks for images, albums, or the gallery, so no possibility of confusig among them.]
Sign In or Register to comment.