We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43454
    • 14 Posts
    Hi!

    I have a problem after moving MODX.
    <?php
    $curCtx = $modx->context->get('key');
    $resources = call_user_func_array(  array('modResource_mysql', 'load'), 
                                        array(& $modx, 'modResource', array('pagetitle' => $pagetitle, 'context_key' => $curCtx), true));
    if ($resources != null) 
        echo $resources->get('id');

    That snippet stop working. I use it to return resource ID by its NAME. call_user_func_array returns nothing - NULL.

    Server parameters:
    MODX - 2.2.6
    mysql - 5.5.29
    PDO - installed, enabled
    other parameters - http://detsad.odinedu.ru/tst.php

    PS snippet IF stop working too.

    This question has been answered by alezru. See the first response.

      • 4172
      • 5,888 Posts
      can't you just use this?

      <?php
      $curCtx = $modx->context->get('key');
      
      if ($resource = $modx->getObject('modResource',array('pagetitle' => $pagetitle, 'context_key' => $curCtx))){
          return $resource->get('id');    
      }
      
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 43454
        • 14 Posts
        Quote from: Bruno17 at Apr 21, 2013, 08:26 AM
        can't you just use this?

        <!--?php
        $curCtx = $modx--->context->get('key');
        
        if ($resource = $modx->getObject('modResource',array('pagetitle' => $pagetitle, 'context_key' => $curCtx))){
            return $resource->get('id');    
        }
        
        It was like that, but i try some other variants and stops on that one, cuz they all do not work.....
          • 43454
          • 14 Posts
          It happens cuz chars encoding. If i write the $pagetitle parameter in ENGLISH it works, but if i will write it in RUSSIAN it stop working.
          Can't find where is a problem. [ed. note: alezru last edited this post 13 years, 5 months ago.]
            • 38290
            • 712 Posts
            Would it make sense to ensure character encoding is identical to that of the old server?
              jpdevries
              • 43454
              • 14 Posts
              The old one:
              character_set_client utf8
              character_set_connection utf8
              character_set_database utf8
              character_set_filesystem binary
              character_set_results utf8
              character_set_server cp1251
              character_set_system utf8
              character_sets_dir /usr/share/mysql/charsets/
              collation_connection utf8_general_ci
              collation_database utf8_unicode_ci
              collation_server cp1251_general_ci

              The new one:
              character_set_client utf8
              character_set_connection utf8
              character_set_database utf8
              character_set_filesystem binary
              character_set_results utf8
              character_set_server cp1251
              character_set_system utf8
              character_sets_dir /usr/share/mysql/charsets/
              collation_connection utf8_general_ci
              collation_database utf8_unicode_ci
              collation_server cp1251_general_ci
              • discuss.answer
                • 43454
                • 14 Posts
                It was because of PHP settings.
                php_admin_value mbstring.func_overload 0 - that what must be in php.ini confinguration file (it wouldnt read that from .htaccess).