Using @inline example, longtitle is not imported

I am following the docs for getResources and can’t get the longtitle to show in my document. I’m using an example directly from the docs that even uses @inline, so as to be certain it will be included, but I’m getting an empty element.

pagetitle is there but longtitle is not. I do have longtitles in the documents so I would expect to see them in the variables after they’ve been evaluated.

Can someone please tell me what I’m missing?

[[getResources? &tpl=`@INLINE <li title="[[+longtitle]]">[[+pagetitle]]</li>`]]

I can’t reproduce this.

Did you check the page source? As you output the longtitle as an attribute of <li>, it’s not visible on the page.

Does this work?

[[getResources? &tpl=`@INLINE <li>[[+longtitle]] | [[+pagetitle]]</li>`]]

Thanks again Harry, sorry to flood your board with all these questions but I’m trying to get this up before the end of next week and there’s so much left to do.

Yes, I’m checking the page source and there isn’t anything in the element. Running your code in the Element gives me:

* | Blog Post 4
* | Blog Post 1
* | Blog Post 2
* | Blog Post 3

The longtitle as you can see isn’t being included.

Does it work correctly if you use a chunk for the &tpl property instead of an @inline template?

I just tried it and I get back an empty “page-title” element:

          <div class="dbody">
            <h3>Blog Post 3</h3>
            <div class="page-title"></div>

Just so you know what I did, in case I didn’t do something right, I added this in the template file first:
[[getResources? &parents=`[[*id]]` &tpl=`blog`]]

…then I added the variable in the chunk and refreshed the screen:
<div class="page-title">[[+longtitle]]</div>

Really weird!

If you open the blog post resource and put [[*longtitle]] in the content, does that work?

I put [[*longtitle]] directly into the blog post resource and as you can see, I get an empty line on #2, which is where I put it. There is just a placeholder on line 1.

I would have figured it would have been as easy as calling out the database column name but it looks like there’s more to it than that. Very weird.

I was able to get this working. Instead of using [[*longtitle]] as the tooltip suggests, I had to use [[+longtitle]]. I’m not sure yet what the difference is between the 2, but if someone can point me to the docs that deal with this, I would appreciate it.

Thanks for all the help, Harry!

Now I’m confused. Isn’t this exactly what you used in your first post?

Read this article about the MODX “Tag Syntax”.

[[*fieldName]] is for the field values (or template variables) of the current resources. (The resource that is called by the HTML-request.)

[[+placeholder]] is the syntax for placeholders. Placeholder values are usually set by PHP code in a snippet.

For example if you have the following structure

example resource tree

and you request “Parent 1” with a template like this

<!-- pagetitle of requested resource -->

<!-- query the child resources and output their pagetitles -->
[[getResources? &tpl=`@INLINE <li>[[+pagetitle]]</li>`]]

<!-- placeholder for the total amount of children (set by getResources) -->

you get the following output:

Parent 1
* Child 1
* Child 2

maybe, you should have a look into the tag syntax docs

[[* is for resource - fields and TVs of the currently visited resource.
[[+ is for placeholders, which are set by snippets. In that case this placeholders are set for the tpl-chunks by getResources

I did try that in both the template and in different chunks but wasn’t able to get it working. What I didn’t mention was that I reinstalled MODX and was only after that, that things started working. I’m not sure what caused it not to work on the first install.

Thank you for the Tag Syntax link and thanks for explaining the difference between placeholders and template variables.

My next hurdle is setting images into every chuck. I think I’ll probably need to use TVs for that, so the docs should come in handy.

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.