Search code examples
modxmodx-revolutionmodx-evolution

Allocate a child resource to two different parents resources (?)


I have a articles blog like so:

(parent) Category: News
(child) article: news-1 written by author-tom
(child) article: news-2 written by author-bill

(parent) Category: Sports
(child) article: sports-4 written by author-bill
(child) article: sports-7 written by author-jack

(parent) Category: Weather
(child) article: weather-1 written by author-tom
(child) article: weather-3 written by author-jack

Author name is a template_variable. And for each article I input the author name manually.

The author names are clickable links. And what I want to achieve is that when a user clicks "author-bill", for example, that the user only sees ALL articles written by "author-bill", thus articles news-2 and sports-4. For "author-jack" the same (sports-7 and weather-3).

I cannot allocate a child to two different parents (i.e. to both the "news" category AND to "author-jack" for example...).

I am stuck in thinking about a feasible solution...


Solution

  • Use getResources to search all your categories for the author name template variable. You don't need to assign multiple parents [though if you insisted on doing that you could use a resource alias to fake it]

    Your getResources would look something like:

    [[!getResources?
         &parents=`1,2,3` // your category ids
         &tvFilters=`author_name==[[+author_name]]` //pass the author in a placeholder
    
    etc. 
    

    Read the docs: http://rtfm.modx.com/extras/revo/getresources