It's an edge case, but instead of using arg() in page_title_page_get_title it would be nice to allow an argument to be passed in so that a site can get the page title that is set for a different page.

This could be handy, for example, if a site is messing with $_GET['q'] page_title_page_get_title will think it's on a different page than it "really" is.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greggles’s picture

Status: Active » Needs review
FileSize
3.09 KB
greggles’s picture

That had some weaknesses.

Due to the way that the token works, it still gets the page-title from a place that uses lots of arg() calls. And those cannot easily be overriden.

For my case, I could work around that by doing a new token that is node specific and setting a page-title pattern for the node-type that is affected by this.

It's not perfect, but it provides a pattern forward.

It is possible to pass in $options to tokens as an alternative method and then we could make page_title_get_title use a similar pattern to the one I setup in page_title_page_get_title.

Also, we need this to run on specific pages and in those specific situations I added this to our preprocess_page which runs after page_title. So, I added the ability to reset the caching in page_title_page_get_title rather than messing with weights (which we can't change for other reasons).

Whew.

greggles’s picture

An alternative idea to make all of this more flexible is to add some drupal_alters to both of those functions.

That's how nodewords gets around this problem and it works reasonably well.

nicholasThompson’s picture

Status: Needs review » Postponed

Thats a very interesting idea... It would allow you to find the generated Page Title for any given path. Hmm.. Worth considering!

As for "hook_alters"... there already are :)
hook_page_title_alter(&$title):
http://drupalcode.org/viewvc/drupal/contributions/modules/page_title/pag...

hook_page_title_pattern_alter(&$pattern, &$types):
Frontpage: http://drupalcode.org/viewvc/drupal/contributions/modules/page_title/pag...
Other Pages: http://drupalcode.org/viewvc/drupal/contributions/modules/page_title/pag...

Other Pages cant use drupal_alter itself as you cant pass 2 references parameters, only 1. but it essentially achieves the same goal.

I'm gonna mark this as postponed as I definitely think this is a good idea - but right now I wanna concentrate on getting a stable 2.4 out with all the new Views loveliness.

c4rl’s picture

Issue summary: View changes
Status: Postponed » Closed (won't fix)

This seems feasible by looking up the alias just querying the table manually and using the alter.