We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 52631
    • 15 Posts
    MODX Revolution 2.5.5
    The error in the snippet Gallery
    Found in the logs an error:
    (ERROR @ /core/cache/includes/elements/modsnippet/12.include.cache.php : 48) PHP warning: Illegal string offset 'total'
    

    12 snippet Gallery, here is some code, 46-48:
    $data = $modx->call('galItem','getList',array(&$modx,$scriptProperties));
    $totalVar = $modx->getOption('totalVar', $scriptProperties, 'total');
    $modx->setPlaceholder($totalVar,$data['total']);


    Please help to fix the error
      • 3749
      • 24,544 Posts
      I'm not sure where $data['total'] is supposed to come from. This will stop the error. It won't necessarily fix the problem, but it might:

      $data = $modx->call('galItem','getList',array(&$modx,$scriptProperties));
      $totalVar = $modx->getOption('totalVar', $scriptProperties, 'total');
      
      /* this is new */
      if (isset($data['total'])) {
          $modx->setPlaceholder($totalVar,$data['total']);
      }


      Obviously, the change needs to be made in the snippet, not the cache. wink
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 52631
        • 15 Posts
        Quote from: BobRay at Mar 14, 2017, 04:33 AM
        I'm not sure where $data['total'] is supposed to come from. This will stop the error. It won't necessarily fix the problem, but it might:

        $data = $modx->call('galItem','getList',array(&$modx,$scriptProperties));
        $totalVar = $modx->getOption('totalVar', $scriptProperties, 'total');
        
        /* this is new */
        if (isset($data['total'])) {
            $modx->setPlaceholder($totalVar,$data['total']);
        }


        Obviously, the change needs to be made in the snippet, not the cache. wink

        Thank you!
        What is the reason? Global error in the Gallery?
          • 3749
          • 24,544 Posts
          Sorry, no idea. You should file it as an issue here: https://github.com/modxcms/Gallery/issues
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 11186
            • 38 Posts
            MODX Revolution 2.5.7

            Identical issue. I had a tv gallery call in a template something like:

            [[*wgallery:notempty=`[[!Gallery? &album=`[[*wgallery]]` &plugin=`galleriffic`]]`]]


            Navigating to a page upon which that call returned 'empty' would toss the OPs error with the number being the gallery snippet id. Removing that call and replacing the template with a direct call to the gallery snippet resolved the issue so far.

            EDIT: When you save a resource without a gallery it defaults to 'none'. It isn't empty, and there is no gallery 'none', hence the error. [ed. note: grabenfub last edited this post 6 years, 11 months ago.]