Вывод количества просмотров в списке статей

Нужно вывести в списке статей количество просмотров для каждой. На странице статьи отрабатывают сниппеты ticketComments и ticketMeta. Полагаю, что этого достаточно для подсчета количества просмотров статей. После добавления параметра select в шаблоне articlePreview перестают работать все плэйсхолдеры. Почему так происходит?
[[!pdoPage? &parents=`22`
            &limit=`10`
            &element=`pdoResources`
            &loadModels=`tickets`
            &showLog=`1`
            &tpl=`articlePreview`
            &where=`{"template:=":4}`
            &leftJoin=`{"View": {"class":"TicketView","alias":"View","on":"modResource.id = View.parent"}}`
            &select=`{"modResource": "*","View": "COUNT(View.parent) as views}"`]]
Алексей
02 мая 2016, 14:02
modx.pro
1
1 248
0

Комментарии: 3

Алексей
03 мая 2016, 22:14
0
? Подскажите, пожалуйста. Думаю, ошибка элементарна.
    Алексей
    04 мая 2016, 23:06
    0
    Вот лог:

    0.0000319: Loaded model «tickets» from "/core/components/tickets/model/"
    0.0001202: pdoTools loaded
    0.0000479: xPDO query object created
    0.0025139: leftJoined TicketView as View
    0.0024831: Processed additional conditions
    0.0029190: Added where condition: template:==4, modResource.parent:IN(22,23,26,31,24,25,32,34,35,36,38,41,42,43,45,46,48,49,50,51,52,54,56,57,58,61,62,70,72,27,28,29,33,37,40,44,47,53,55,59,60,30,39,63,64,65,66,67,68,69,71), modResource.published=1, modResource.deleted=0
    0.0001400: Sorted by modResource.publishedon, DESC
    0.0000041: Limited to 10, offset 0
    0.0006731: SQL prepared «SELECT `modResource`.`id` AS `modResource_id`, `modResource`.`type` AS `modResource_type`, `modResource`.`contentType` AS `modResource_contentType`, `modResource`.`pagetitle` AS `modResource_pagetitle`, `modResource`.`longtitle` AS `modResource_longtitle`, `modResource`.`description` AS `modResource_description`, `modResource`.`alias` AS `modResource_alias`, `modResource`.`link_attributes` AS `modResource_link_attributes`, `modResource`.`published` AS `modResource_published`, `modResource`.`pub_date` AS `modResource_pub_date`, `modResource`.`unpub_date` AS `modResource_unpub_date`, `modResource`.`parent` AS `modResource_parent`, `modResource`.`isfolder` AS `modResource_isfolder`, `modResource`.`introtext` AS `modResource_introtext`, `modResource`.`content` AS `modResource_content`, `modResource`.`richtext` AS `modResource_richtext`, `modResource`.`template` AS `modResource_template`, `modResource`.`menuindex` AS `modResource_menuindex`, `modResource`.`searchable` AS `modResource_searchable`, `modResource`.`cacheable` AS `modResource_cacheable`, `modResource`.`createdby` AS `modResource_createdby`, `modResource`.`createdon` AS `modResource_createdon`, `modResource`.`editedby` AS `modResource_editedby`, `modResource`.`editedon` AS `modResource_editedon`, `modResource`.`deleted` AS `modResource_deleted`, `modResource`.`deletedon` AS `modResource_deletedon`, `modResource`.`deletedby` AS `modResource_deletedby`, `modResource`.`publishedon` AS `modResource_publishedon`, `modResource`.`publishedby` AS `modResource_publishedby`, `modResource`.`menutitle` AS `modResource_menutitle`, `modResource`.`donthit` AS `modResource_donthit`, `modResource`.`privateweb` AS `modResource_privateweb`, `modResource`.`privatemgr` AS `modResource_privatemgr`, `modResource`.`content_dispo` AS `modResource_content_dispo`, `modResource`.`hidemenu` AS `modResource_hidemenu`, `modResource`.`class_key` AS `modResource_class_key`, `modResource`.`context_key` AS `modResource_context_key`, `modResource`.`content_type` AS `modResource_content_type`, `modResource`.`uri` AS `modResource_uri`, `modResource`.`uri_override` AS `modResource_uri_override`, `modResource`.`hide_children_in_tree` AS `modResource_hide_children_in_tree`, `modResource`.`show_in_tree` AS `modResource_show_in_tree`, `modResource`.`properties` AS `modResource_properties` FROM `modx_site_content` AS `modResource` LEFT JOIN `modx_tickets_views` `View` ON modResource.id = View.parent WHERE ( `modResource`.`template` = 4 AND `modResource`.`parent` IN (22,23,26,31,24,25,32,34,35,36,38,41,42,43,45,46,48,49,50,51,52,54,56,57,58,61,62,70,72,27,28,29,33,37,40,44,47,53,55,59,60,30,39,63,64,65,66,67,68,69,71) AND `modResource`.`published` = 1 AND `modResource`.`deleted` = 0 ) ORDER BY modResource.publishedon DESC LIMIT 10 „
    0.0073602: SQL executed
    0.0002029: Total rows: 10
    0.0001469: Rows fetched
    0.0025311: Loaded chunk “articlePreview»
    0.0532079: Returning processed chunks
    0.0679080: Total time
    13 369 344: Memory usage

    Вроде всё правильно. Может быть при использовании leftJoin нужно добавлять префиксы к плейсхолдерам?
      Wassi Wassinen
      07 января 2017, 00:22
      0
      У вас в итоге получилось построить запрос?
      Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
      3