I have a news article content type that has a pattern like this:

news/[node:field_news_published_date:date:custom:Y]/[node:field_news_published_date:date:custom:m]/[node:field_news_published_date:date:custom:d]/[node:title]

The problem is the published date is set automatically when the article is first published, so the "published date" field will be empty if the article is saved as a draft. This results in the path being set to news/[node:title].

What I'd like is the ability to tell pathauto to skip creating the alias under certain condition (like if the news article is not published yet). This could be done by pathauto dispatching an event that modules can subscribe to or invoking a hook that modules can implement.

I looked at the code in the PauthauoGenerator service but looks like there's no opportunity to do this.

Comments

bkosborne created an issue. See original summary.

Berdir’s picture

We have pathauto_pattern and at least one issue to update its documentation and figure out if it is still useful. Being able to skip completely could be one possible use case for it?

bkosborne’s picture

Yeah I saw that hook and looked into if there was a way I could manipulate it to do nothing, but there's doesn't seem to be a straightforward way. I couldn't find the docs issue.

Berdir’s picture

bkosborne’s picture