Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Say we set the page title pattern as this:
[page-title] | [term] | [vocab] | [site-name]
If there's no vocab/term for a given page, the page title will be generated as this:
My title | | | My site
There are 3 separators in a row. Page title module should have an option to clear no needed separators. For example, for the previous url, we would have:
My title | My site
Comments
Comment #1
asb CreditAttribution: asb commentedThis is not a bug, but a feature request. I'd love to see something like this also, but I have no idea how the UI could look.
Clearly the 'Page Title' module must not remove separator characters like "|", "-", ":" (or whatever the user has chosen as separator, it might be even a text string) at it's own discretion; so probably it'd be necessary to segment the title into tokens and it's belonging-to separator characters, maybe with a syntax like
{[page-title] | }{[term] | }{[vocab] | }{[site-name]}
(if{...}
is empty, do not display), or a extended UI.Greetings, -asb
Comment #2
jonaswouters CreditAttribution: jonaswouters commented+1
Comment #3
nicholasThompsonNow THAT is a nice idea! Not sure what the overhead would be of breaking up a string and parsing each segment individually would be...
It could also be hard to detect...
{[page-title] and then} some other {[term:name]} text
... if page-title was empty, the optional segment would not be empty (it'd be { and then}).I wonder if this would be a better suited feature request for Token. Then Token could do the replaces using a regex callback... Something like "if you find a token inside curly braces, pass the result into a function. This function returns blank if the replacement string for the token is empty, otherwise it does a normal string replacement on the token"...
Comment #4
komlenic CreditAttribution: komlenic commentedConditional Tokens, or Token Logic have apparently been discussed in various places before. See #354039: Token logic module patch It seems unlikely to happen.
This idea may have merit to be a possible clue to a solution: http://drupal.org/node/279491#comment-1214029
I'm marking this issue as a duplicate of #876880: Conditional display of token value with surrounding characters / Optional Tokens, even though the descriptions and ideas here are very good.
Comment #5
komlenic CreditAttribution: komlenic commentedI solved the duplicate title separator problem by adding this to a custom module: