modxmodx-revolutionmodx-resourcesmodx-templates

Create article preview in ModX?


How can I create preview of my articles(which are in the resource "articles") using their [[*description]] and [[*introtext]] in the right sidebar on another resources page, called "services"(this page's (template) code:

<html>
<head>
<title>[[++site_name]] - [[*pagetitle]]</title>
<base href="[[++site_url]]" />
</head>
<body>
[[*content]]

</body>
</html>

)

I created new tpl, called it "article_story" with this code:

<p><a href="[[++site_url]][[~[[+id]]]]">[[+pagetitle]]<br>
<img alt="[[+pagetitle]]" src="[[+tv.image:phpthumbof=`w=300`]]"></a><br>
[[+introtext]]<br>
</p>

I've tried to use this code:

[[!getResources? &parents=`[[*id]]` &tpl=`article_story` &limit=`3` &sortby=`{"publishedon":"ASC","createdon":"DESC"}`]] 

But it doesn't work. Any thoughts?


Solution

  • By default the getResources Extra doesn't include unpublished Resources. You need to add &showUnpublished to the snippet call:

    [[!getResources? 
        &parents=`[[*id]]` 
        &tpl=`article_story`
        &showUnpublished=`1` 
        &limit=`3` 
        &sortby=`{"publishedon":"ASC","createdon":"DESC"}`
    ]]