Pages do not fall into breadcrumbs and cannot be redirected to

Hi there,

I’m maintaining a site where some of the pages seem to be created incorrectly.
For example, there are two internal pages:

“Page 1” with url: /services/solutions/page1
“Page 2” with similar url: /services/solutions/page2
As for breadcrumbs I have:
“home”-> “services”-> “solutions” / page 1
“home” / page 2

So for Page 2 crumbs not work for some reason (pdoCrumbs used) , although [[*uri]] return proper page URL. Second unpleasant moment of this page is that it is impossible to make a redirect to such a page from Formit.

There is some problem with creating a link/addressing, but I don’t understand at all what else needs to be checked.

What has already been done and did not help:

  1. Container flag - enable disable
  2. Same for “Hide from menus”
  3. Freeze URL flag, alias
  4. Publication - changed back and forth
  5. Сhanged parent for Page 2, moved it up and down … full address changes, breadcrumbs do not.
  6. Сompared the resources and all the fields related to them in the database … I don’t see a difference
  7. Disabled SEO, redirects, other plugins…

This is the first time I’ve encountered this, please tell me what can affect this. It turns out that some resources were created by the client in such a strange way, the rest are correct.

MODX 2.8.3

Thanks in advance,

I don’t think pdoCrumbs uses the URL to generate the breadcrumbs. I think it uses the parents in the resource tree.

When you add the showLog property to your snippet call

[[!pdoCrumbs? &showLog=`1`]]

what are the “Added where condition” in the log output? Are all the parent-resources in the id:IN(...) list?

Hi @halftrainedharry ,
Thanks for your answer!

I don’t think pdoCrumbs uses the URL to generate the breadcrumbs. I think it uses the parents in the resource tree.

You’re right of course, I didn’t say that, I just said that you can see the difference here :slight_smile:

Here is pdoCrumbs log difference:
Page 1 pdoCrumbs log fragment:

0.0000920: Added selection of modResource: `id`, `type`, `contentType`, `pagetitle`, `longtitle`, `description`, `alias`, `alias_visible`, `link_attributes`, `published`, `pub_date`, `unpub_date`, `parent`, `isfolder`, `introtext`, `content`, `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`
0.0000730: Added where condition: published=1, deleted=0, id:IN(3626,21,1)
0.0000341: Sorted by find_in_set(`modResource`.`id`,'3626,21,1'),

Here: page ID = 3626, 21 = parent ID, 1 = root page ID
Page 2 pdoCrumbs log fragment:

0.0000930: Added selection of modResource: `id`, `type`, `contentType`, `pagetitle`, `longtitle`, `description`, `alias`, `alias_visible`, `link_attributes`, `published`, `pub_date`, `unpub_date`, `parent`, `isfolder`, `introtext`, `content`, `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`
0.0000720: Added where condition: published=1, deleted=0, id:IN(3917,1)
0.0000350: Sorted by find_in_set(`modResource`.`id`,'3917,1'),

Here 3917 is page ID, but parent ID (21) is absent here for some reason (resources share same parent!). How does it possible? Second one is container, but I moved it’s child nodes to other, changed container flag with cache clearance and url rebuild, no success.

The pdoCrumbs snippet gets the parents from the modx function getParentIds().

Is the parent list also wrong if you call this code in a snippet?

return json_encode($modx->getParentIds($modx->resource->id, 10, ['context' => $modx->resource->get('context_key')]));

Page 1 output:


Page 2 output:


I guessed it was a parent issue before I got to the end. :wink:

I originally wrote SiteCheck because I ran across several similar problems. I think when you drag things around in the tree, MODX can get confused about the parent/child relationships. Is the parent wrong or blank in the database?

I’m not sure whether SiteCheck would help you or not. It changes the parent of all resources with invalid or troublesome parents to the SiteCheck Problem Resources folder.

Thanks @bobray !

Just installed and checked website, there are no errors especially about parent resources, “SiteCheck Problem Resources” is empty (though I not selected “Attempt to fix errors” flag )

Is the parent wrong or blank in the database?

No problems with that field in DB.

My guess is that the context_key is wrong for this resource. Maybe some whitespace in the key?

The function getParentIds() reads the information from the cache. Specifically the resourceMap in the files core/cache/context_settings/{context_key}/context.cache.php. Maybe take a look at these files.

One of the other things SiteCheck looks at is whether every resource’s context_key value matches the parent’s context_key value. If it doesn’t, that could explain your problem.

Rats, I would have bet a fair amount that SiteCheck would turn up something.

Did you try clearing the cache manually and visiting in Incognito or Private mode? That would eliminate cache (browser and MODX) issues.

Page 1 ID presents inside map (as child of 21 resource): 3626

resourceMap array:

 21 => 
    array (
      0 => 161,
      1 => 3626,
      2 => 3722,
      3 => 3388,
      4 => 73,
      5 => 74,
      6 => 3524,
      7 => 3881,

Page 2 ID absent at all (and as child of 21 resource), ID= 3917

this is very strange … 3917 resource looks completely normal in resource manager, but for some reason it does not get into the map. I’m checking again all DB field values … but I do not see any errors

This is the SQL query used to generate the resourceMap. (Replace 'web' with the actual name of your context.)

FROM `modx_site_content` `r` 
FORCE INDEX (`cache_refresh_idx`) 
LEFT JOIN `modx_context_resource` `cr` ON `cr`.`context_key` = 'web' AND `r`.`id` = `cr`.`resource` 
WHERE `r`.`deleted` = 0 
	AND (`r`.`context_key` = 'web' OR `cr`.`context_key` IS NOT NULL) 
GROUP BY `r`.`parent`, `r`.`menuindex`, `r`.`id`, `r`.`uri`

Unless the context_key is wrong in modx_site_content or the resource is deleted, I see no reason why it shouldn’t be in the result. Maybe run some queries in phpMyAdmin to test it.

Hi @halftrainedharry ,
Thanks for this. I queried this and can see both resources.

2022-05-17 11.10.58

That’s very weird. Every row of this query should get added to the resourceMap: