MODX 3.x Content Type Icon

Hi all,

MODX 3 seems to have a new field allowing the specification of an icon for each Content Type.

My question is - is it possible to access this setting when listing static resources?

So, say I’m listing various static resources in a container using pdoResources.

I can output the likes of [[+pagetitle]] - but is there now an easy way to also output the Content Type Icon for that resource?

I have achieved this previously using snippets to apply suitable icons - just wondering if there is now an easier way?

Thanks in advance.

The icon is stored in the modx_content_type table and with pdoResources you generally query the resources in modx_site_content.

There is the possibiliy to add joins to the pdoResources call to connect to other database tables.
Code like this seems to work (but I’m not sure how helpful this really is).

[[pdoResources?
    &parents=`0`
    &tpl=`@INLINE <p>{{+pagetitle}} ({{+id}}) - Icon: {{+icon}}</p>`
    &select=`{
        "modResource": "*",
        "ContentType": "icon"
    }`
    &leftJoin=`{
        "ContentType": {"class":"modContentType", "alias":"ContentType"}
    }`
]]
1 Like

It does indeed work, thanks for that, Harry.

However, I take your point about it perhaps not actually being that useful since we’d have to load and use the same icon fonts on the front end - not the end of the world but somewhat limiting. Good to know it can be done but I’ll stick with my original method for now.

Also useful to learn that pdoResources can accept joins :+1:

Thanks as always.

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”.