Frage

I can't get a result with getResource anymore.

For example, I want to query my blog posts: My articles are created with the Articles plugin.

In my template, I have:

[[!getResources:ifempty=`No Resource`? &parents=`33` &showHidden=`1` ]]

It simply shows "No Resource". Without the ifempty tag, it simply doesn't show anything.

The weird thing is I know I have those articles in my database. When I try with the parameter debug=true, I see the article objects' dump in place of the template. So the query is working fine, getResource retrieves the articles when debug is set to true!

With debug, I can see the SQL query in my log file:

[2014-02-10 16:58:37] (ERROR @ /huayang/index.php) context for 33 is web [2014-02-10 16:58:37] (ERROR @ /huayang/index.php) SELECT modResource.id, modResource.type, modResource.contentType, modResource.pagetitle, modResource.longtitle, modResource.description, modResource.alias, modResource.link_attributes, modResource.published, modResource.pub_date, modResource.unpub_date, modResource.parent, modResource.isfolder, modResource.introtext, modResource.richtext, modResource.template, modResource.menuindex, modResource.searchable, modResource.cacheable, modResource.createdby, modResource.createdon, modResource.editedby, modResource.editedon, modResource.deleted, modResource.deletedon, modResource.deletedby, modResource.publishedon, modResource.publishedby, modResource.menutitle, modResource.donthit, modResource.privateweb, modResource.privatemgr, modResource.content_dispo, modResource.hidemenu, modResource.class_key, modResource.context_key, modResource.content_type, modResource.uri, modResource.uri_override, modResource.hide_children_in_tree, modResource.show_in_tree, modResource.properties FROM modx_site_content AS modResource WHERE ( modResource.parent IN (33,34,35,36) AND modResource.deleted = 0 AND modResource.published = 1 ) ORDER BY publishedon DESC LIMIT 5

When I run this query directly in phpmyadmin, I get the articles!

To be clear, getResource simply won't work whatever the query I try to make, if debug isn't set to true. It won't show my any error at any point..

I have already uninstalled and reinstalled the plugin.

So.. any idea how I can fix this? Any suggestion how I should proceed to debug this?

Edit: getresources-1.6.1-pl

Edit2:

Started debugging, snippet.getresources.php, line 430

$collection = $modx->getCollection('modResource', $criteria, $dbCacheFlag);

$collection is an empt array.. $criteria is a xPDOQuery_mysql Object which looks correct..

I'm gonna sleep through this and will reinstall ModX tomorrow if I can't fix this

War es hilfreich?

Lösung

The issue was that my template was in Templates instead of Chunks, the snippet started working again after I moved articlePreview into Chunks.

Some kind of output would have helped..

Hope this can help someone.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top