# pdoResources and checking total value

**URL:** <https://community.modx.com/t/pdoresources-and-checking-total-value/2239>\
**Category:** Extras\
**Created:** [February 8, 2020, 6:38pm UTC](https://community.modx.com/t/pdoresources-and-checking-total-value/2239 "2020-02-08T18:38:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apathy](https://community.modx.com/letter_avatar_proxy/v4/letter/a/2bfe46/32.png) [@apathy](https://community.modx.com/u/apathy)\
**Post date:** [February 8, 2020, 6:38pm UTC](https://community.modx.com/t/pdoresources-and-checking-total-value/2239/1 "2020-02-08T18:38:20Z")

</div>

Hello

I have pdoResources returning the number of records using &setTotal=`1` and if I add [[+total]] to my code, it correctly shows the number of entries.

I am trying to test the value to vary what is shown depending on the value of [[+totals]] but nothing seems to work. I have tried the if using output modifiers and the If addon – can you see if you can get it to work?

I have:

Total: [[+total]]

[[+total:greaterthan=`0`:then=`SHOW ME`:else=`HIDE ME`]]

which shows:

Total: 2  
HIDE ME

Is +total a different data type as it does not have a length (not a string) and cannot be compared?

James

---

<div class="post-metadata">

**Author:** ![nick2687](https://community.modx.com/user_avatar/community.modx.com/nick2687/32/805_2.png) [@nick2687](https://community.modx.com/u/nick2687)\
**Post date:** [February 9, 2020, 3:43am UTC](https://community.modx.com/t/pdoresources-and-checking-total-value/2239/2 "2020-02-09T03:43:02Z")

</div>

Can you show a sample of your entire snippet call / code?

I tested this by putting the below directly into an empty resource and it outputted `SHOW ME` (as well as a list of the resources) as I would have expected.

```auto
[[!pdoResources?
    &parents=`2`
    &depth=`2`
    &tpl=`testChunk`
    &setTotal=`1`
]]
[[+total:greaterthan=`0`:then=`SHOW ME`:else=`HIDE ME`]]

```

---

<div class="post-metadata">

**Author:** ![apathy](https://community.modx.com/letter_avatar_proxy/v4/letter/a/2bfe46/32.png) [@apathy](https://community.modx.com/u/apathy)\
**Post date:** [February 9, 2020, 11:23pm UTC](https://community.modx.com/t/pdoresources-and-checking-total-value/2239/3 "2020-02-09T23:23:01Z")

</div>

The code is supposed to show the other art from the artist. This is in the Art template.  
I have:

```
[[!pdoResources? 
	&parents=`6`
	&showLog=`0`
	&depth=`1`
	&sortby=`{"artid":"ASC"}`
	&includeTVs=`ArtistsID,ArtTitle,artid`
	&where=`{ "ArtistsID:=" : "[[*ArtistsID]]", "AND:artid:!=" : "[[*artid]]" }`
	&returnIds=`0`
	&toPlaceholder=`MoreListings`
	&setTotal=`1`
	&tpl=`ArtListing`
]]

<p> Total: [[+total]]</p>
<p>[[+total:greaterthan=`0`:then=`SHOW ME`:else=`HIDE ME`]]</p>

```

`[[+MoreListings]]`

The where links the artists and the art together and the second part excludes the current page thjat we are on from the listing. This is displayed by MoreListings and works fine.

For Total, I am getting 1 and HIDE ME

Logs are:

`0.0000751: pdoTools loaded 0.0000210: xPDO query object created 0.0006931: Included list of tvs: **artid, ArtistsID, ArtTitle** 0.0001431: leftJoined *modTemplateVarResource* as **TVartid** 0.0000870: leftJoined *modTemplateVarResource* as **TVartistsid** 0.0000830: leftJoined *modTemplateVarResource* as **TVarttitle** 0.0001402: Added selection of **modResource** : <small>SQL_CALC_FOUND_ROWS `id`, `type`, `contentType`, `pagetitle`, `longtitle`, `description`, `alias`, `alias\_visible`, `link\_attributes`, `published`, `pub\_date`, `unpub\_date`, `parent`, `isfolder`, `introtext`, `richtext`, `template`, `menuindex`, `searchable`, `cacheable`, `createdby`, `createdon`, `editedby`, `editedon`, `deleted`, `deletedon`, `deletedby`, `publishedon`, `publishedby`, `menutitle`, `donthit`, `privateweb`, `privatemgr`, `content\_dispo`, `hidemenu`, `class\_key`, `context\_key`, `content\_type`, `uri`, `uri\_override`, `hide\_children\_in\_tree`, `show\_in\_tree`, `properties`</small> 0.0000069: Added selection of **modTemplateVarResource** : <small>IFNULL(`value`, '') AS `tv.artid`</small> 0.0000050: Added selection of **modTemplateVarResource** : <small>IFNULL(`value`, '') AS `tv.ArtistsID`</small> 0.0000041: Added selection of **modTemplateVarResource** : <small>IFNULL(`value`, '') AS `tv.ArtTitle`</small> 0.0000260: Replaced TV conditions 0.0004599: Processed additional conditions 0.0006661: Added where condition: **`TVartistsid`.`value`:==4, AND:`TVartid`.`value`:!==A23, modResource.parent:IN(6,7,8,9), modResource.published=1, modResource.deleted=0** 0.0000100: Replaced TV conditions 0.0000720: Sorted by **`TVartid`.`value`** , **ASC** 0.0000019: Limited to **10** , offset **0** 0.0003080: SQL prepared <small>"SELECT SQL_CALC_FOUND_ROWS `modResource`.`id`, `modResource`.`type`, `modResource`.`contentType`, `modResource`.`pagetitle`, `modResource`.`longtitle`, `modResource`.`description`, `modResource`.`alias`, `modResource`.`alias\_visible`, `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`, `modResource`.`hide\_children\_in\_tree`, `modResource`.`show\_in\_tree`, `modResource`.`properties`, IFNULL(`TVartid`.`value`, '') AS `tv.artid`, IFNULL(`TVartistsid`.`value`, '') AS `tv.ArtistsID`, IFNULL(`TVarttitle`.`value`, '') AS `tv.ArtTitle`FROM`modx\_site\_content`AS`modResource`LEFT JOIN`modx\_site\_tmplvar\_contentvalues` `TVartid`ON`TVartid`.`contentid`=`modResource`.`id`AND`TVartid`.`tmplvarid`= 11 LEFT JOIN`modx\_site\_tmplvar\_contentvalues` `TVartistsid`ON`TVartistsid`.`contentid`=`modResource`.`id`AND`TVartistsid`.`tmplvarid`= 13 LEFT JOIN`modx\_site\_tmplvar\_contentvalues` `TVarttitle`ON`TVarttitle`.`contentid`=`modResource`.`id`AND`TVarttitle`.`tmplvarid`= 9 WHERE (`TVartistsid`.`value`= '4' AND`TVartid`.`value`!= 'A23' AND`modResource`.`parent`IN (6,7,8,9) AND`modResource`.`published`= 1 AND`modResource`.`deleted`= 0 ) ORDER BY`TVartid`.`value` ASC LIMIT 10 "</small> 0.0017581: SQL executed 0.0001910: Total rows: **1** 0.0000219: Rows fetched 0.0046301: Prepared and processed TVs 0.0026400: Loaded "modChunk" with name "ArtListing" 0.0030320: Returning processed chunks 0.0121272: **Total time** 4 194 304: **Memory usage** `
