Git Product home page Git Product logo

getresources's People

Contributors

bartholomej avatar cjholowatyj avatar freejung avatar jpdevries avatar mattsenior avatar opengeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

getresources's Issues

Sort by TV

Enable sorting of getResources results by TV value

e.g. &sortby=tv.value

Sortby Template Variables?

This is my snippet call

[[getResources? &parents=0 &where={"template:=":3} &tvFilters=productInSlider==true &includeTVs=1 &tpl=productHomeSlider &limit=&sortbyTV=productSliderPos &sortby=]]

Where my 'productInSlider' tv is a checkbox to determine if a resource is need to be shown here (i'm planning to make a content-slider) and the 'productSliderPos' is a number tv for the sort-direction.

I'm getting 5 times wat I want a single time and getting once the same wat I want but onundered.

  • resource 1
  • resource 2
  • resource 1
  • resource 2
  • resource 1
  • resource 2
  • resource 1
  • resource 2
  • resource 1
  • resource 2
  • resource 2
  • resource 1

Regards, Bert

Feature Request: Ability to specify (limit) which TVs are to be returned

I have noticed that using getResources to aggregate documents based on TVs, in particular, can be very slow.

It looks like this is because every resource field and every TV on each of the specified resources is being returned to the array.

A useful feature might be the ability to specify, or limit, which TVs are to be queried, in order to speed things up a bit.

Select resources directly

Allow to select resources directly (not by their parents) and add them to the collection by, say, &resources=id[, id]``? It should be possible not to select any parents, and collect only resources of choice. Of course, the &depth parameter should be ignored in this case.

That will allow to collect resources into a hand made list and, in special case, return value for a single resource similarly to getField snippet for Evo.

Sort by resource list reverse order

I've noticed, if I use sortBy to give getResources a list of resource id's, when it comes to output them, it does so in the reverse order to that which is stated in the list. For example, say we have
[[!getResources? &resources=[6,1,55,7,25 &limit=``&tpl=my_tpl&includeTVs=`1`&processTVs=`1`&sortby=`FIELD(modResource.id, 6,1,55,7,25 )`]]

..what we get back are resources ordered as 25,7,55,1,6

This is with getResources 1.3.1

Improve caching issues

I have a website with pages which contain 3 getResources calls. The site has become really slow now. I've turned the getResources calls off and on and they're definitely the source of my problems. Can getResources' caching ability be vastly improved?

Ignoration of "tpl_{n}" parameter when snippet called with property set

Case #1.
I've created a property set myPropertySet for getResources and added, e.g., tpl_5 parameter. When calling a snippet by [[getResources@myPropertySet]] everything is OK despite tpl_5 parameter is ignored and every 3d item is considered 'odd' (as by default).
Case #2.
I've created a property set myPropertySet for getResources and added tpl_5 parameter when calling a snippet: [[getResources@myPropertySet? &tpl_5='myTplOdd']] everything is OK but tpl_5 parameter is ignored again and every 3d item is considered 'odd' (as by default).

Typo in options array()

'options' => array(
array('text' => 'ascending','vaue' => 'ASC'),
array('text' => 'descending','value' => 'DESC'),

Causing troubles in propety sets

Children not displayed when parent is in a different context

I've probably found a bug...

When I have a snippet call in context A and my parent folder is in context B, then the children of my parent folder are not displayed (as they would if the snippet call is also in context B).

This behavior was also described by an other user at the forum: http://forums.modx.com/thread/70160/getresources---multiple-contexts-children-wrong#dis-post-392986

My snippet call (in context "api"):
[[!getResources:default=No results found? &parents=4 &limit=0 &sortbyTV=event-date &sortdirTV=ASC &where={"template:=":3} &hideContainers=1 &includeContent=1 &includeTVs=1 &processTVs=1 &tvPrefix=`` &tpl=api-event &context=data ]]

If I use this in the context "data" it works like expected.

SQL error when no parent resources specified

I just tried getResources for the first time. Tried calling it with no arguments and I get an SQL error:
[2010-09-10 12:02:45](ERROR @ /index.php) Error 42000 executing statement:
Array
(
[0] => 42000
[1] => 1064
[2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1,4,12,16,18,19,20,21,22,23,5,6,7,8,9,10,11,13,14,15,17) AND (modResource.`con' at line 1
)

Side note: this error goes to the error log in 1.1.0ga, but outputs in the calling resource in 1.1.0pl.

The problem seems to be with the 'parents' value. It is defined as a property but with no value. I think because it is defined as a property, it is passing "isset($parents)" in the definition line.

Setting the property value to 0 fixes the problem.

&processTVs leads to PHP warning

After updating to 1.1.0 pl I get the following PH warning when processing TVs:

[2010-08-02 17:18:14] (ERROR @ /secret/folders/core/model/modx/modtemplatevar.class.php : 422) PHP warning: DirectoryIterator::__construct(/secret/folders/core/model/modx/processors/element/tv/renders/SecretContextName/output/) [directoryiterator.--construct]: failed to open dir: No such file or directory

The TV which is being processed looks like this:

@SELECT pagetitle FROM modx_site_content WHERE parent = 73

I use this as an alternative to the "tags" TV of the blog example (http://svn.modxcms.com/docs/display/revolution20/Creating+a+Blog+in+MODx+Revolution). Basically I want the tags to be documents within a folder (73).

Missing placeholders in MODX 2.1.2-pl

Actually, I'm using 2.2-dev but this one appeared after upgrade thus the title. I fetch a descriptive name for content_type via Rowbot and it doesn't work now. The Rowbot call sits inside template chunk used by getResources:

[[[email protected]?where=`{"id:=":"[[+content_type]]"}`]]

However, once I place [[+content_type]] in the chunk directly then both the Rowboat output and content_type display! I had to cloak Rowboat call like this:

[[+content_type:ifnotempty=`[[[email protected]?where=`{"id:=":"[[+content_type]]"}`]]`]]

That works but is not a solution as content_type is always present and I guess a similar issue may happen with other nested snippet calls.

I also tried a TV with the first Rowboat call as default value in place of the direct snippet call inside a chunk. This didn't work either in getResources output while worked correctly when called directly from a resource.

Using get resources twice in a page, generated MySQL gets wrong parent ids

Hi there,

Here is the Document layout i have:

Root
-home
-page1
---factorsandquestionscontainer
------factorandquestion1 (template id = 7)
------factorandquestion2 (template id = 7)
---audiocontainer
------audio1 (template id = 6)
------audio2 (template id = 6)

Here are the calls that are within the same template, one after the other as below:

[[!getResources? &parents=[[*id]] &tpl=CMM-CC-factorsandquestionstpl &where={"template:=":7} &includeTVs=1 &processTVs=1 &sortby={"pagetitle":"ASC"}&cache=0]]

[[!getResources? &parents=[[*id]] &tpl=audiotpl &where={"template:=":6} &includeTVs=1 &processTVs=1 &sortby={"pagetitle":"ASC"}&cache=0]]

The first call brings back as expected, the second doesn't. Here is the debug mysql generated, it appears that the latter call does not correctly pass the parent ids in as the parent ids of the audio is 36 in the site_content table:

[2011-05-05 19:26:07](ERROR @ /csquared/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.haskeywords, modResource.hasmetatags, modResource.privateweb, modResource.privatemgr, modResource.content_dispo, modResource.hidemenu, modResource.class_key, modResource.context_key, modResource.content_type FROM site_content AS modResource WHERE ( ( modResource.parent IN (14,16,24,26) AND (modResource.context_key IN ('web') OR EXISTS(SELECT 1 FROM context_resource ctx WHERE ctx.resource = modResource.id AND ctx.context_key IN ('web'))) ) AND modResource.deleted = 0 AND modResource.published = 1 AND modResource.hidemenu = 0 AND modResource.template = 6 ) ORDER BY pagetitle ASC LIMIT 5

if you need anymore info to help, just let me know,

thanks,
Lee

Allow chunk parameters and property sets in template calls

Chunk parameters ie. equivalent to [[$chunk?param=value]] can't be used in &tpls.

That would particularly useful for altering template chunks for use with &tplFirst, &tplLast etc., where it would allow to use a single chunk with a variable.

Children of Hidden Parents

[[!getResources? &parents=0,-25 &limit=0 &tpl=sitemap &sortby={"pagetitle":"ASC"}]]

  • resource 25: hide from menu ticked, is a parent to a few children that aren't hidden from menu
  • getResources, hides the parent (-25) but shows its children.
  • tried hiding resource 25 through &resource=-25 but to no avail
  • another detail, that may help, is that resource 25 is a child of another parent (that isn't hidden from menu)

No idea why this is happening, it should hide documents under that parent :)

Broken in 2.1.2-pl?

I just did a update of my site (from 2.1.1-pl to 2.1.2-pl) and now all elements generated by getResources are not visible...
Tried a reinstall of getResources but it does not work. There are no errors in the log.

My call:
[[!getResources? &resources=[[$settings_page_id]] &tpl=chunk_footer_contact &includeTVs=1 &processTVs=1 &tvPrefix=``]]
It worked before the update....

I also tried:
[[getResources? &resources=[[$settings_page_id]] &tpl=chunk_footer_contact &includeTVs=1 &processTVs=1 &tvPrefix=``]]

It worked before the update...

Anybody else got this?

Issue with including TV list

I'm having some problems selecting a single TV to be included and processed. When I run the below, the TV called articleThumbnail is not returned (although it does return resources sans that). If I don't include the TVLists, the TV comes back fine. Why is this?

Below I specify the TV name in double-quotes as it's a string but no joy with it coming back

[[!getResources? &resources=`[[*hpHighlightsIDlist:default=`3`]]` &limit=`` &tpl=`tpl_SubPageDirList` &includeTVs=`1` &processTVs=`1` &includeTVList=`"articleThumbnail"` &processTVList=`"articleThumbnail"` &sortby=`{"FIELD(modResource.id,[[*hpHighlightsIDlist:default=`3`]])","ASC"}` &parents=`-1`]] 

With debug mode on, the SQL is

[2011-10-29 06:12:12] (ERROR @ /index.php) context for -1 is 
[2011-10-29 06:12:12] (ERROR @ /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` FROM `modx_site_content` AS `modResource` WHERE  (  ( modResource.parent IN (-1) AND `modResource`.`deleted` = 0 AND `modResource`.`published` = 1 AND `modResource`.`hidemenu` = 0 )  OR `modResource`.`id` IN (13,14,25,4) )  

Specifying it without quotes yields the following error:

[2011-10-29 06:09:52] (ERROR @ /path_to_site/core/cache/includes/elements/modsnippet/10.include.cache.php : 384) PHP warning: in_array(): Wrong datatype for second argument

If I specify just the id numbers of the TV, it returns nothing.

Feature: getResources from unpublished pages

When I'm rolling out a new set of pages, it would be very useful to be able to
test my getResources calls against unpublished sources. Ideally, getResources
would figure out the published status of the calling page.

  • If the caller is published, keep the existing behaviour with the 'published'=>1 criteria.
  • If the not published, getResources would ideally return both published and unpublished results

Reading symlinks and their values

For a project we have made a list with resources inside a category page. In an other category page we have made a symlink to a resource somewhere else in the website. This works great but only the the overview of symlinks doesn't have all information from the symlink page.

What I would like to have is all information (like fields and tvs) from the resource where the symlink was made to. I hope you will understand and maybe this is a good fix for working with symlinks

For now I have manually fixed this in the getresources snippet

@INLINE template and [[~[[+id]]]]

I just found that the [[+id]] placeholder doesn't work when it's placed inside a link tag if I used a @inline template code.
It does work on @file or chunk.

[[!getResources? &tpl=@INLINE <a href="[[~[[+id]]]]" title="[[+pagetitle]]">[[+pagetitle]] ([[+id]]) </a>]]

It is only the [[+id]] inside the link that is missing.

Selecting single resources and sortby the way it's selected

I have a getResources tag like

[[!getResources? &resources=1,12,13,14,6,7,20 &tpl=myChunk &limit=``&depth=0]]

I would like select the specified resources but somehow the current page his childs will be added and the order of the items is on menuindex or publishedon field.

It should be great if the order is the same as the resources I entered in the parameter and to not loading the subpages of the current page. Currently I have added the parents parameter with the ID of the homepage (1) wich has no subpages to load no other pages.

I hope you understand

processTVList doesnt seem to be working as intended. Suggested Solution

Hi there,
With this getResources call
[[getResources? &depth=0 &includeTVs=1 &includeTVList=general-page-img &processTVList=general-page-img &sortby=menuindex &sortdir=DESC &parents=[[*id]] &limit=100 &tpl=getResources_subseclist_menuindex]]

The general-page-img TV is being returned but not processed. From the documentation it appears that processTVs=1 is not required (although to be honest it seems strange that you need both includeTVs and includeTVList together. Surely if you are being specific the includeTVList alone would be enough).

In the getResources snippet (1.4.0) on line 378 it has
if ($processTVs && (empty($processTVList) || in_array($templateVar->get('name'), $processTVs)))

I changed mine to

if (!empty($processTVList) && in_array($templateVar->get('name'), $processTVList))

and my TV began processing again. Whether or not this is the correct fix I am not 100% sure however it seems that in teh currecnt code it is looking for the name in the processTVs variable (it should be the processTVList variable shouldnt it?

Secondly the first part of the if seems to be requiring processTVs to be set to 1 before it will allow it past that condition.

Thoughts?

Currently I am assuming this area is bugged. Please let me know otherwise.

kind regards

Marcushouse

Extremely slow execution time

Two issues in as many days - apologies however this is a big one. One of my getResources requests takes 2.5 seconds to complete but more worrying is the below which takes nearly 7 seconds and only has to return 5 items. How can this be optimised??

[[!getResources? &resources=`[[*hpHighlightsIDlist:default=`3`]]` &limit=`` &tpl=`tpl_SubPageDirList` &includeTVs=`1` &processTVs=`0` &sortby=`{"FIELD(modResource.id,[[*hpHighlightsIDlist:default=`3`]])","ASC"}` &parents=`-1`  &debug=`1`]] 

The TV hpHighlightsIDlist contains five resource ID's

From the error log

[2011-10-31 15:43:14] (ERROR @ /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` FROM `modx_site_content` AS `modResource` WHERE  (  ( modResource.parent IN (-1) AND `modResource`.`deleted` = 0 AND `modResource`.`published` = 1 AND `modResource`.`hidemenu` = 0 )  OR `modResource`.`id` IN (13,14,25,4) )  
[2011-10-31 15:43:20] (ERROR @ /index.php) modSnippet: getResources executed in 6.3166 s

Enhancing tvFilter:

I've done some modification to getResources to accomodate more TVFilters condition operators such as :
!=
EXISTS
NOTEXISTS
| : for OR operator

And changed that the "OR" "|" condition will only effect after the main condition is meet, etc. published='1' and deleted='0'

Examples:
tvFilters= mytv!=%xxx%|mytv==NOTEXISTS
Setting condition to TV mytv does not contain tag "xxx" or no mytv variable exists

getResources2.php
http://www.mercstudio.net/assets/media/getResources2.php.zip

sortorder=`RAND()` interferes with cache_db system setting

Even on an uncached page and within an uncached snippet call the sortorder parameter set to RAND() doesn’t produce a new sort order on every page reload (as one would expect it) as long as the system setting cache_db is enebled.

Disabling the database cache is a possible fix. But that means that database caching is not available for the whole website – even if there is just one single getResources call with a random sortorder. It would be great if database caching could always be bypassed by getResources calls which include a sortorder parameter set to RAND().

Disregards TV Image File Manager Path

When using a getresources call in 2.1.0 rc4 that includes a TV image, the output doesn't include the File Manager Path set in System Settings. This is my tpl -
[[+pagetitle]] or
[[+pagetitle]]

And when output looks like this -
When it should be -

tvFilters does not catch default on checkbox

If I have a checkbox TV with a value of 1 and the default is 1 I cannot use the tvFilters parameter to filter on that value. For example a TV set up as:
Variable Name: test_var Input Type: checkbox Input Option Values: True==1 Default Value: 1 Output Type: Default

This call should pull up resources with this TV checked:
[[!getResources? &parents=[[*id]] &tpl=my_tpl &includeTVs=1 &processTVs=1 &tvFilters=test_var==1]]

It does not work. I think MODX stores a flag to indicate default value instead of the actual default value.

Feature Request: Add support for tree hierarchy

getResources processing yields a flat view of a resource tree.

There are application where a tree view would be beneficial and a tree view cannot be achieved by chaining getResources calls as parameters (eg filter parameters) cannot be passed down the chain. Other snippets which create a tree, like WayFinder on the other hand do not support filtering.

There is currently a work around using a snippet called getResourcesTree (refer to http://modxcms.com/forums/index.php/topic,43832.msg333619.html#msg333619) but it would be nice to have such a functionality integrated into getResources.

I am happy to provide a patch with that feature integrated using sortby='tree' as a way to configure this feature. I also would then add an additional template tplContainer so containers can be renderd differently.

0-based idx

Setting a custom "idx" start value of 0 ( [[getResources? .. &idx=0]] ) doesn't work, because the value is checked using empty, which returns true for a 0 value and sets the idx to the default value of 1. The snippet code at about line 264 needs to change to this:

$idx = (empty($idx) && $idx !== '0') ? 1 : intval($idx);

Improve New User Friendliness

Having the snippet dump the fields array as a default behavior freaks out new users and gives them little feedback about what is wrong.

Two thoughts:

  1. Return "Tpl Chunk Not Found" and add a &debug property that dumps the fields.
  2. Put a message at the top of the fields array, e.g.,: "Tpl Chunk Not Found. Displaying resource fields for each resource."

Remove the limit of 5

Setting the &limit parameter to '5' doesn't make much sense. I expect to see ALL the results coming back to me, not just the last 5. Make it so that the default value of &limit is set to unlimited. Just like Ditto.

If only &resources is specified, getResources uses current resource for parent

When cherry-picking resources for selection, it is sometimes necessary to use only &resources, with no &parent specified. If you do this, however, getResources apparently defaults to the ID of the current resource for &parent, with annoying consequences. In the situation where I encountered this, I had to work around it by specifying a resource for &parent that has no children - however, that isn't a permanent solution.

If workable, I suggest that the logic be changed to have no default value for &parent, but to use only the resources specified in &resources, if it is present and &parent is not.

Add support for factor-based tpls

Factor based tpl's would allow users to define a tpl for every nth item in the result, providing the tpl for the greatest factor of the current item specified. For example, you might have:

&tpl_n3=`EveryThirdItemTpl` &tpl_n6=`EverySixthItemTpl`

This should allow easy creation of markup to support columns and other complex layouts.

PHP error when &parents is unset

With &parents unset the following PHP error is returned:

(ERROR @ /index.php) Error 42000 executing statement: Array ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘1,2,3,4,5,7) AND (modResource.context_key IN (‘web’) OR EXISTS(SELECT 1 FROM’ at line 1 )

When unset &parents should default to [[*id]] or be ignored if &resources is set.

CRITICAL: adding special characters in longtitle prevents RSS listing

I have a multi-lingual blog (french / english)
I use getResources for my RSS feeds.
The english feed works perfectly, since no special characters (letters with accents) are used in english.
how-ever, my french feed would only fetch a rare few blog entries.
After fighting for quite a while with it, I discovered that a special character in the "longtitle" of the document prevents that document from loading into the rss feed.

in my case the character was "é"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.