I had everything setup and working correctly and then all of the sudden I noticed one day that my view modes pages weren't working anymore! The culprit turned out to be the Extended Path Aliases module.

Disabling the module restores my functionality of view mode pages setup like: example.com/[node-alias]/%/[view-mode-machine-name]

This has me resorting to using the syntax of the Display Suite module like: example.com/[node-alias]?v=[view_mode_machine-name]

This later syntax isn't very pretty and I would love to keep using the View Mode Page module, but need the Extended Path Aliases module also so...

Any ideas on a patch or a fix?

Thanks ahead of time!

Comments

rballou’s picture

I'm currently looking into this.

rballou’s picture

Alright, this is mostly a brain dump of what I've figured out so far e.g., not necessarily a fix. I'm personally unfamiliar with Extended Path Aliases, so this probably shows exposes that.

Firstly, I confirmed that installing path_alias_xt (PAXT) does break view_mode_page (VMP) functionality.

Secondly, I found the point where this breaks but I'm trying to still understand the best way to fix it. So here's where things stand so far:

VMP works by adding the pattern to the menu routing table. So if you have a pattern of article/%/teaser, you'll have a menu_router record with that pattern that then calls view_mode_page_change_entity_view_mode. This menu record still exists with PAXT installed.

Where things break down is PAXT implements hook_inbound_url_alter here: http://drupalcode.org/project/path_alias_xt.git/blob/d26b378399e96fc2e89.... If you comment out line 98, VMP will work (but I assume PAXT does not work).

To configure a "test" for this, I have a content type called article with the full and teaser view modes. Article has an image field, title, and body. Teaser just shows title and body. I have a pattern setup so articles are: article/[node:title] and the VMP pattern as: article/%/teaser. With just VMP, this will work (you'll see the teaser mode when going to article/example/teaser. So with PAXT installed you'll see the full mode and not the teaser mode. The hook_inbound_url_alter code will return: node/1/teaser. Without line 98, the code that calls this will be article/example/teaser.

One possible solution that comes to mind is to add both the VMP pattern and also a "source" VMP pattern. The trick will likely be getting an entities base "source" path and identifying how that works with a the VMP. In my example, this is fairly simple ... maybe. You have a pretty simple path with only one wildcard. This may be more complicated with with multiple wildcards.

Another point of concern with getting this to work is that the last commit for PAXT was 2 years ago. This isn't a problem if it's fixable on the VMP side or if the maintainer for PAXT is available, just something to consider.

sreynen’s picture

This looks like a bug in PAXT to me. Specifically, it should not be altering inbound paths that match wildcard menu_router items. It's already excluding exact matches from alters, but not wildcard matches, and Drupal is full of wildcard paths. Just quickly skimming the PAXT bug list, it looks like many of the open bugs relate to similar breaking paths of other modules that use wildcard paths. So this should maybe be moved over to that queue, and several bugs could be fixed at once with a wildcard exclude added.

rballou’s picture

Project: View Mode Page » Extended Path Aliases
Version: 7.x-2.2 » 7.x-1.0

Moving this over to Extended path aliases. If this is something that needs to be fixed on the VMP side, please let me know.

rdeboer’s picture

There should be some improvement with the latest version of Extended Path Aliases, as the menu-router table is now checked for the parent paths as well.
Not sure it will fix all cases.

rdeboer’s picture

Issue summary: View changes
Status: Active » Closed (fixed)

Closing based on latest comment and inactivity.