Closed (fixed)
Project:
Page Title
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Sep 2008 at 07:21 UTC
Updated:
14 Jul 2012 at 19:33 UTC
I have a custom module that registers custom tags.
When I enter [mycustomtag] in Pattern for Story (or any content type) but override it on the node form by populating the page title field I see [mycustomtag] instead of the custom text for the title.
Although this patch does what I need it to do, I'm not confident that this is a good way to solve the problem.
| Comment | File | Size | Author |
|---|---|---|---|
| page_title.module.patch | 939 bytes | j0hn-smith |
Comments
Comment #1
nicholasthompsonThe Page Title field on the nodes does not accept tokens in it. It is simply a field which can be used AS a token when you configure the pattern for the node.
Comment #2
j0hn-smith commentedI'm not entering a token in the Page Title field on the node form.
Page Title default settings (Default Pattern): [mycustomtag]
node form Page Title field: 'I want this text to replace the custom tag.'
When I try this the title shows as '[mycustomtag]', but I'm not sure why. When the field on the node form is blank the title shows the custom tag as expected. The problem only occurs when text is input into the node form field.
Basically the field in the node form only overrides [page-title], I'd like to be able to choose a different token to override instead. Maybe this should be a feature request?
Many thanks
Comment #3
nicholasthompsonErr... Why do you want to override a different token? Whats wrong with [page-title]?
If you create your own module which implements the token hooks and is in either the global or the node scope then you can declare your OWN
[mycustomtag]which can be used in the default pattern...Apart from that, the Page Tile field overrides the [page-title] and nothing else. I cant see a genuine use-case for having a configurable token placeholder. Maybe I'm missing something?
Comment #4
j0hn-smith commentedThat is exactly what I'm doing. But as I specified [mycustomtag] in the defaults, this is the tag I want to override to change the html page title.
I should just overwrite [page-title] in my module instead of creating a custom tag I think.
Sorry for wasting your time.
Comment #5
nicholasthompsonCan you provide your [mycustomtag] token implementation code please? I have a feeling this is more of a token issue than a Page Title issue as any token which is in the global scope or the node scope (assuming its a node page) will have complete access to the tokens...
Page Titles Token implementation is:
Comment #6
j0hn-smith commentedIf I use either [page-title] or [longname] in the admin/content/page_title/settings defaults they display correctly, but neither gets overridden by text entered in the page-title field on the node form. I understand that this field only overrides [page-title] so there's no reason why it should change [longname].
Here's the code I'm using to create the tokens.
I think the problems are caused by different token scopes, the use of array_merge in the tokens module and possibly the module weight in the system table. I've created a support request against tokens #304333: How can I overwrite [page-title] from my custom module? re the array_merge issue, maybe a patch for tokens is necessary to overwrite the duplicates instead of merge them?
I just want to be able to overwrite [page-title] with for all nodes, and override [page-title] for a specific node using the field on the node form - drupal should be able to handle this.
Comment #7
j0hn-smith commentedNicholas, can I discuss this with you on IRC? What time of day are you around (UTC)?
Thanks
Comment #8
nicholasthompsonI might be around today, right now i'm HUGELY busy migrating several dozen websites between 2 servers.
I'm wondering if your problem here is that - alphabetically speaking - your module gets run before mine. If you're module either had a higher weight OR was called "zzzz_general_page" then it would probably get run after...
Comment #9
j0hn-smith commentedThank for taking the time to discuss this, I appreciate that you're busy.
I played with the weights but that didn't change anything.
I'd started hacking both page-title and tokens which isn't a good idea so I decided to leave tokens alone and make my own custom version of page-title that does what I need it to do. It's not a large module so the maintenance should be minimal.
Page-title, as it stands, is a great module - it's just that my requirements for it are obscure.
Many thanks for your help.
Comment #10
nicholasthompsonThe do seem a little "edge" ;-)
I'm still a little hazy why you want to create a new field with a new token instead of using the [page title] token/field. You could probably even use a CCK field as an alternative if you really want a separate field?!
The conversation has spawned another thought though... I might implement a "hook_page_title_alter" where other modules can be written to modify the page title after is generated. I might even create an earlier hook so that other modules can DEFINE their page title.
Comment #11
j0hn-smith commentedI didn't want another field, I wanted to use the page-title field but for a different token.
I already had another token that contained the value I wanted to use, my original thinking was to use that token but when I realised that would 'go against the grain' I decided to use [page-title]. I thought it would be as simple as [page-title] = [mytoken], unfortunately not.
That sounds like the sort of functionality I'm after, especially the second part.
If you're interested I can show you my custom page-title module.
Comment #12
nicholasthompsonThat'd be good. You can either attach it here or if you use my contact form I will reply back so we can contact via email.
Marking this as fixed for now. Will start a new thread about the features.
Comment #13
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.