In the previous article, we looked at how to keep the MODX Forums from eating your back-ticks. In this one we'll look at some reasons why getResources and pdoResources might not be showing your TV values.
Suppose you have a call to getResources or pdoResources that contains TV tags in the Tpl chunk, but some or all of the TV values are not showing up or don't look like they should. There are several reasons this might be happening. The following issues will occur is both getResources, and its faster replacement pdoResources.
I'll refer to getResources in the sections below, but remember that most of the points will apply equally to pdoResources. If there are differences between the two, I'll tell you about them.
TVs not Connected to the Template
If a TV is not connected to the current resource's template, there's no way it can be accessed by getResources. This mistake is fairly rare, since you would notice that the TV was missing when you edited the resource.
If the TV is protected with an Element Category Access ACL entry, and the current user doesn't have the proper access, attempts to access the TV can fail. Similarly, if the TV contains a reference to a protected Media Source, the attempt to access it can also fail.
You may have permission to set the value of the TV, but the user visiting the front end may not.
This property must be set if you have TV tags in your Tpl chunk. The use of this property is not the same for getResources and pdoResources. For getResources, the property should be
`1` (the default value is
`0`). If that's all you do, getResources will prepare to set placeholders for all TVs attached to the resource. If you have many TVs, but will only be displaying some of them, you can speed things up by adding the
&includeTVList property, which should contain a comma-separated list containing the names of the TVs you need to show.
For pdoResources, there is only one property,
&includeTVs which should contain a comma-separated list of the names of the TVs you want to show.
If your TVs are connected to a Media Source, this property tells MODX to take the necessary steps to display the TV value properly. As with
&includeTVs above, getResources will prepare all TVs if you use
&prepareTVs=`1`. It will only prepare the ones you want prepared if you use
&prepareTVList with a comma-separated list of the TV name.
For pdoResources, the comma-separated list of TV names goes in the
If you need the processed value of the TV, rather than the raw value stored in the TV value, you need to include this property. For example, if you have an image TV, and expect to have a full HTML image tag replace the placeholder, you need to ask for the processed value of the TV.
Once again, getResources takes two properties:
&processTVList with a comma-separated list of the TVs that need processing.
The pdoResources snippet tag takes a single property,
&processTVs with a comma-separated list of the TV names.
With getResources, the second property in each pair (
&processTVList) are optional. It's recommended that you always use them, though, because including, preparing, and processing TVs is a relatively slow process and there's no point in having MODX perform those operations on TVs that you won't be displaying.
This isn't an issue with pdoResources, since it requires you to specify the TVs you want included, prepared, and/or processed in the pdoResources tag.
This is the one that most often trips people up. For both getResources and pdoResources, the default prefix is
tv.. You not only need to include it in the names of your TVs, but also in the properties above.
It's a matter of personal preference, but there's seldom a reason to include a TV prefix. The only case I can think of is if you have a TV with the same name as a resource field (e.g., a TV called
description) and those TVs can easily be renamed to avoid collisions.
Adding the prefix to every TV takes time, and it's easy to forget to add the prefix when specifying the TVs in the properties above, so my recommendation is to never use TV prefixes and *always* include this property in your getResources or pdoResources tag:
If your TVs have no prefix and you don't set the
&tvPrefixproperty as shown above, your TVs won't show up in the results.
In the next article, we'll look at how to include other extras in a transport package.
Looking for high-quality, MODX-friendly hosting? As of May 2016, Bob's Guides is hosted at A2 hosting. (More information in the box below.)