I use the filter [G2:xxxx] syntax to show photos in my node but I found if the photo is an album (the g_canContainChildren field of g2_item table is "1"), I can see the photo. But if the photo is a photo only (g_canContainChildren is "0"), then I only see "[G2:xxxx]" in node.

It worked in some previous version (a dev version, before beta1), sorry, I cannot remember the exactly date. I also uninstall this module and install again but get the same problem.

Comments

profix898’s picture

Component: gallery_content.module » Miscellaneous

If I use [G2:65] where itemId=65 is a photo, it works fine for me ...

dennys’s picture

Thanks, it seems my problem. But is there any suggestion for me to debug it ? I have no idea how to find the problem.

profix898’s picture

Component: Miscellaneous » Filter / G2Image

You can try two things:

  1. Embed the following code in your node (using php filter) to manually fetch the image block from G2:
    <?php
    $params = array(
      'blocks' => 'specificItem',
      'itemId' => 65 // itemId of your photo
    );
    $block = gallery_get_block($params, 2);
    print $block['content'];
    ?>

    If it does not work either, there is something wrong in G2.

  2. Put print_r($params); into place, right before the call to getImageBlock() in gallery_filter.inc. This prints out a list of parameters passed to getImageBlock(). You should see at least the two options specified above (specificItem and id).
dennys’s picture

1. I used php filter to run the code, it works for both album and photo.
2. The following is the output of print_r($params); when I press submit button. 1001 is a photo, 1704 is an album, the output seems the same ?

Array
(
    [class] => nowrap
    [show] => title
    [link] => 
    [itemId] => 1001
    [blocks] => viewedImage|viewedImage|viewedImage|viewedImage|viewedImage|viewedImage|viewedImage|viewedImage|viewedImage
    [maxSize] => 150
    [albumFrame] => book
    [itemFrame] => flicking
    [linkTarget] => 
)
Array
(
    [class] => nowrap
    [show] => title
    [link] => 
    [itemId] => 1704
    [blocks] => viewedImage|viewedImage|viewedImage|viewedImage|viewedImage|viewedImage|viewedImage|viewedImage|viewedImage
    [maxSize] => 150
    [albumFrame] => book
    [itemFrame] => flicking
    [linkTarget] => 
)
profix898’s picture

Title: filter only works for album, not photo » Filter doesnt work for [G2:x] syntax if n>1 is default value
Category: support » bug
Status: Active » Fixed

Aha. Thats indeed a bug in the module. I guess you have specified a default number of images >1 (9 in your case?) in the filter settings. The filter code uses this instead of n=1 if the simple [G2:x] syntax is used. Bugfix for this committed. Thanks.
Please let me know if I still missed something ;)

dennys’s picture

Status: Fixed » Closed (fixed)

My default number is 3. I changed it to 1 and it's (2.0-beta5) ok. Then I downloaded the new cvs and changed the default number to 3, it's ok too. Thanks.