We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12994
    • 26 Posts
    getResource вызываю в сниппете... пытаюсь получить плейсхолдер:
    $modx->getPlaceholder('total');

    ничего не возвращает... точнее null.

    подскажите, пожалуйста, как мне не выводить сниппет, если getRes возвращает null.
    заранее благодарен. [ed. note: int99h last edited this post 15 years, 2 months ago.]
      • 12994
      • 26 Posts
      $sql = "SELECT *
      FROM `it_site_content`
      INNER JOIN `it_site_tmplvar_contentvalues`
      ON it_site_tmplvar_contentvalues.contentid = it_site_content.id
      AND it_site_tmplvar_contentvalues.tmplvarid = 17
      AND it_site_content.parent = 18
      AND it_site_tmplvar_contentvalues.value LIKE '%$id%'";
      $res = mysql_query($sql);
      $num = mysql_num_rows($res);

      ничего не возвращает... хотя должно возвращать 1 (проверял запрос в phpMyAdmin)

      может кто-то поможет с конструкцией типа:
      $c = $modx->newQuery('modResource');
      $c->leftJoin('modTemplateVar','contentid');
      $c->where(array(
          'modResource.published' => 1,
          'modResource.parent' => 18,
          'modTemplateVar.tmplvarid' => 17,
          'modTemplateVar.contentid' => 'modResource.id',
          'modTemplateVar.value:LIKE' => '%$id%',
      ));
      $c->sortby('menuindex','ASC');
      $c->limit(10,10);
        
      $resources = $modx->getCollection('modResource',$c);
      $num = count($resources);
      

      быть может это поможет.... [ed. note: int99h last edited this post 15 years, 2 months ago.]
        • 31246 ☆ A M B ☆
        • 428 Posts
        если вы посмотрите внимательно снипет getResource, то после строчки 266
        last = empty($last) ? (count($collection) + $idx - 1) : intval($last);

        добавьте
        $modx->setPlaceholders('total',count($collection));

        тогда вы смело можете использовать
        $modx->getPlaceholder('total');


        если вы в снипете вызываете снипет getResource , попробуйте просто
        $total = count($collection);
          Valentin Rasulov - Industrial design (Hobbies - Web Development)
          Development not standard projects on CMF MODx Revolution.
          Small sample of extensions
          • 12994
          • 26 Posts
          Artdevue,
          спасибо... помогло.
          $num = $modx->getPlaceholder('total');
          возвращает правильное значение.

          еще один вопрос:
            $results = $modx->runSnippet('getResources', array(
          	'parents' => 18,
          	'depth' => 5,
          	'limit' => 5,
          	'includeTVs' => 1,
          	'processTVs' => 1,
          	'includeContent' => 1,
          	'paginateAlwaysShowLinks' => 1,
          	'tvFilters' => 'components==%$id%',
                  'tpl' => 'ListItem',
                  'tplLast' => 'ListLast',
                  'totalVar' => 'totalsol'
          ));


          'tvFilters' => 'components==%$id%',
          не обрабатывается :\ [ed. note: int99h last edited this post 15 years, 2 months ago.]
            • 31246 ☆ A M B ☆
            • 428 Posts
            ок, как вы вызываете, можно код посмотреть?.....
              Valentin Rasulov - Industrial design (Hobbies - Web Development)
              Development not standard projects on CMF MODx Revolution.
              Small sample of extensions
              • 12994
              • 26 Posts
              up
              PS: или код всего сниппета дать?
                • 12994
                • 26 Posts
                <?php
                /* get curentproduct id */
                  $id=$modx->resource->get('id');
                  $result = "";
                  if (!empty($id)) {
                
                  /* list output */
                  $result = "
                    <div>Header text</div>
                    <ul>
                    ";
                  $result .= $modx->runSnippet('getResources', array(
                	'parents' => 18,
                	'depth' => 5,
                	'limit' => 5,
                	'includeTVs' => 1,
                	'processTVs' => 1,
                	'includeContent' => 1,
                	'paginateAlwaysShowLinks' => 1,
                	'tvFilters' => 'components==%'.$id.'%',
                        'tpl' => 'ListItem',
                        'tplLast' => 'ListLast',
                        'totalVar' => 'totalsol'
                ));
                  $result .= "</ul>";
                    }
                $num = $modx->getPlaceholder('totalsol');
                if ($num == 0) {$result = "";}
                  return $result;
                
                  • 31246 ☆ A M B ☆
                  • 428 Posts
                  а если вместо $id поставить число (id ресурса), будет обрабатывать?
                    Valentin Rasulov - Industrial design (Hobbies - Web Development)
                    Development not standard projects on CMF MODx Revolution.
                    Small sample of extensions