Closed (duplicate)
Project:
Page Title
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Feb 2009 at 17:51 UTC
Updated:
19 Mar 2012 at 20:31 UTC
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 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 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 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 commentedI solved the duplicate title separator problem by adding this to a custom module: