We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30593
    • 119 Posts
    Собственно мигрирую с evo на revo, возникли вопросы по getResources:
    вызов из шаблона
    было
    [*id:is=`2`:then=`{{NEWS}}`:else=`{{CONTNEWS}}`*]

    стало:
    [[*id:is=`2`:then=`[[$NEWS]]`:else=`[[$CONTNEWS]]`]]


    NEWS:
    было:
    [[Ditto? &parents=`2` &extenders=`summary,dateFilter` &dateSource=`pub_date` &tagData=`documentTags` &tpl=`ditto_news` &summarize=`5` &paginate=`1` &paginateAlwaysShowLinks=`1`]]
    
    
    <div id="ditto_pages"> [+previous+] [+pages+] [+next+] </div>


    стало:
    [[!getResources? &parents=`2` &tpl=`ditto_news` &limit=`5`  &sortdir=`DESC` &sortby=`menuindex` &depth=`0` &includeContent=`1` &includeTVs=`1`]]
    
    
    <div id="ditto_pages"> [[!+page.nav]] </div>
    - навигация не показывается!

    ditto_news:
    было:
    <h1 class="date">[+date+]</h1>
    <h4 class="style4"><b><a href="[~[+id+]~]">[+pagetitle+]</a></b></h4>
    
    <div align="center"><a href="[~[+id+]~]">[+phx:if=`[+image:len+]`:gt=`0`:then=`<img src="[+image+]" width="180" alt="" />`+]</a></div>
    
    <h6><p>[+content:character_limit=`200`+]</p></h6>
    
    <h5 class="cut"><a href="[~[+id+]~]" title="[+pagetitle+]">Read more</a> →</h5>
    
    


    стало:
    <h1 class="date">[[+publishedon:strtotime:date=`%b %d %Y`]]</h1>
    <h4 class="style4"><b><a href="[[~[[+id]]]]">[[+pagetitle]]</a></b></h4>
    
    <div align="center"><a href="[[*id]]"><img class="alignleft" title="[[*article_image_title]]" src="[[+tv.image:phpthumbof=`w=180`]]" alt=""/></a></div>
    
    <h6><p>[[+content:ellipsis=`200`]]</p></h6>
    
    <h5 class="cut"><a href="[[~[[+id]]]]" title="[[+pagetitle]]">Read more</a> →</h5>
    
    


    и CONTNEWS:
    <div>
    <div class="leftPhoto3"><span class="style13">[[*longtitle]]</span></div>
    
    <div align="center">[[!if? [[*article_image]]=`0` &then=`<img src="[[*article_image]]" width="450" alt="" />`]]</div>
    
    
    <p>[[*content]]</p>
    
    <div class="back"><<a href="Javascript:history.back()">back</a></div>
    </div>
    - вот тут не могу спрятать фото если его нет, сниппет IF + не выводит фото [ed. note: Trent last edited this post 14 years, 9 months ago.]
      • 31246 ☆ A M B ☆
      • 428 Posts
      1)
      [[*id:is=`2`:then=`[[$NEWS]]`:else=`[[$CONTNEWS]]`]]
      замените на
      [[*id::isequalto=`2`:then=`[[$NEWS]]`:else=`[[$CONTNEWS]]`]]
      хотя и is должно обрабатывать
      2) NEWS:
      [[!getPage?  &elementClass=`modSnippet`  &element=`getResources`  &parents=`2` &depth=`0` &limit=`5` &pageLimit=`10` &sortby=`{"createdon":"DESC"}`  &pageVarKey=`page`  &includeTVs=`1`  &includeContent=`1`  &tpl=`ditto_news` ]]
      <div class="clear"></div><div class="paging"><ul class="pageList"> [[!+page.nav]]</ul></div>

      3) ditto_news:
      <h1 class="date">[[+publishedon:strtotime:date=`%b %d %Y`]]</h1>
      <h4 class="style4"><b><a href="[[~[[+id]]]]">[[+pagetitle]]</a></b></h4> 
      <div align="center"><a href="[[~[[+id]]]]"><img class="alignleft" title="[[+tv.article_image_title]]" src="[[+tv.image:phpthumbof=`w=180`]]" alt=""/></a></div> 
      <h6><p>[[+content:ellipsis=`200`]]</p></h6> 
      <h5 class="cut"><a href="[[~[[+id]]]]" title="[[+pagetitle]]">Read more</a> �</h5>
      Здесь вы не заменили *id и не понятно что за *article_image_title, я предположил, что это TV.
      4) CONTNEWS:
      [[!if? [[*article_image]]=`0` &then=`<img src="[[*article_image]]" width="450" alt="" />`]]

      замените на
      [[*article_image:notempty=`<img src="[[*article_image]]" width="450" alt="" />`]]


      Фильтра - http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters+%28Output+Modifiers%29

      Может что и пропустил....
        Valentin Rasulov - Industrial design (Hobbies - Web Development)
        Development not standard projects on CMF MODx Revolution.
        Small sample of extensions
        • 30593
        • 119 Posts
        [[!getPage?  &elementClass=`modSnippet`  &element=`getResources`  &parents=`2` &depth=`0` &limit=`5` &pageLimit=`10` &sortby=`{"createdon":"DESC"}`  &pageVarKey=`page`  &includeTVs=`1`  &includeContent=`1`  &tpl=`ditto_news` ]]


        почему-то вывел пустую страницу.

        спасибо за помощь, article_image - это мой tv по выводу изображений к новости
          • 31246 ☆ A M B ☆
          • 428 Posts
          Бывает и такое... встречал не раз. Вы установили расширения getResources и getPage?
            Valentin Rasulov - Industrial design (Hobbies - Web Development)
            Development not standard projects on CMF MODx Revolution.
            Small sample of extensions
            • 30593
            • 119 Posts
            getPage не установил) спасибо!
            и еще вопросик: добавил в index.php файл строчку setlocale(LC_ALL, 'ru_RU.UTF-8');
            дата все равно отображается квадратами


            UPD. по дате решил так:
            [[+publishedon:strtotime:date=`%d`]]
             [[!dateCorectFull? &datc=`[[+publishedon:strtotime:date=`%m`]]`]]
             [[+publishedon:strtotime:date=`%Y`]]


            где сниппет dateCorectFull:
            $context = $modx->context->get('key');
            switch ($context) {
            case 'web':
                $corect= array('01'=>'Январь','02'=>'Февраль','03'=>'Март','04'=>'Апрель','05'=>'Май','06'=>'Июнь','07'=>'Июль','08'=>'Август','09'=>'Сентябрь','10'=>'Октябрь','11'=>'Ноябрь','12'=>'Декабрь');
                break;
            case 'uk':
                $corect = array('01'=>'Січень','02'=>'Лютий','03'=>'Березень','04'=>'квітня','05'=>'Травень','06'=>'Червень','07'=>'Липень','08'=>'Серпень','09'=>'Вересень','10'=>'жовтня','11'=>'листопада','12'=>'Грудень');
                break;
            default:
                $corect = array('01'=>'January','02'=>'February','03'=>'March','04'=>'April','05'=>'May','06'=>'June','07'=>'July','08'=>'August','09'=>'September','10'=>'October','11'=>'November','12'=>'December');
                  }
             return strip_tags(strtr($datc, $corect));



            Не получается переделать вызов со второй странички:
            [[Ditto? &parents=`3` &orderBy=`myDate ASC` &dateSource=`myDate` &dateFormat=`%d.%m.%Y - %H:%M` &tagData=`documentTags` &tpl=`ditto_afisha` &extenders=`summary` &summarize=`50` &paginate=`0` &paginateAlwaysShowLinks=`1]]

            стало:
            [[!getResources?  &parents=`3` &depth=`0` &sortbyTV=`myDate` &sortdirTV=`ASC` &dateFormat=`%A | %d.%m | %H:%M` &pageVarKey=`page`  &includeTVs=`1`  &includeContent=`1`  &tpl=`ditto_afisha2` ]]
            


            где
            myDate - tv для ввода даты события
            те в Ditto у меня шла сортировка по дате указанной через TV [ed. note: Trent last edited this post 14 years, 9 months ago.]
              • 31246 ☆ A M B ☆
              • 428 Posts
              в index.php не нужно добавлять, добавьте в файл core/config/config.inc.php, если не поможет, тогда в сам снипет getResources.Сниппет dateCorectFull я писал, он удобен если нужно склонять месяц.
              Не получается переделать вызов со второй странички
              добавьте параметр
              &processTVs=`1`
                Valentin Rasulov - Industrial design (Hobbies - Web Development)
                Development not standard projects on CMF MODx Revolution.
                Small sample of extensions
                • 30593
                • 119 Posts
                вроде все правильно в ditto_afisha, но не выводит TV, дату, цену

                <div class="afishanewblock">
                <div class="afishanewblockimg">
                <a href="[[~[[+id]]]]"><img class="alignleft" title="[[+pagetitle]]" src="[[+tv.image:phpthumbof=`w=197`]]" alt=""/></a></div>
                <h10><b><a class="titleblack" href="[[~[[+id]]]]" >[[+pagetitle]]</a></b></h10>
                
                <h1 class="dateB"><b>[[*myDate]]</b></h1>
                
                [[+content:ellipsis=`400`]]
                
                <div class="cenarating">
                <div class="cena"><div class="someClass" title="Цена">[[*cena]]</div></div>
                <div class="ratingBlock2">
                  <a href="javascript:;" class="good" id="rating[[+id]]"><img src="manager/templates/img/hand5.png" width="11" title="Мне нравится!" class="someClass"/></a><span>[[*rating]]</span>
                 </div>
                </div>
                </div>


                cena, myDate, rating - TV
                [ed. note: Trent last edited this post 14 years, 8 months ago.]
                  • 31246 ☆ A M B ☆
                  • 428 Posts
                  [[*myDate]]
                  замените на
                  [[+tv.myDate]]

                  и так остальные TV
                    Valentin Rasulov - Industrial design (Hobbies - Web Development)
                    Development not standard projects on CMF MODx Revolution.
                    Small sample of extensions