Use path to give the address
lomz - April 3, 2008 - 07:33
| Project: | |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
WOuld it be possible for twitter.module to use the path-adress to the nodes instead of /node/nid?

#1
Isn't this already happening?
The !url wildcard in the Text format field goes through the url() function, which should return an alias if it exists, seems to be working fine when I looked just then.
#2
On my twitter it just says /node/number/
#3
Oh - looks like you have to fiddle with the module weights to make sure that twitter runs _after_ pathauto. The first time I tried this it worked right away, must have been the order I installed the modules or something?
#4
Probably, how do I do that?
I installed the path module for some months ago and I do not really want to remove it.
#5
you can either crack open your database and do something similar to
UPDATE system SET weight=10 WHERE name='twitter'or i think there is a module you can install that with add something to the module admin page so you can change the order from there. I have never actually used the module, but it is this one: http://drupal.org/project/moduleweight#6
Or perhaps Twitter could just tell itself to have a higher weight? Here's a patch that does just that (inspired by the way Pathauto makes itself heavier, for those who want to know).
I chose 3 as that's heavier than most modules (with a default weight of 0), and heavier than Pathauto's weight of 1 while still not being in the extreme end (like 10), so other modules have plenty of room to fit themselves in "late" in the processing.
#7
Marked #265434: Not using URL aliases as duplicate of this.
#8
And #293232: Not using alias for URLs? as well.
#9
Yes, this seems a viable solution. Pathauto seems like a utility module installed nearly everywhere, so should be respected in a case like this.
#10
Why is it twitter_update_6003 though? I only see 6001 in the current dev version. Is there another patch in the queue with an update?
#11
That's a good question. I honestly can't remember why I chose _6003. :)
#12
My biggest concern is that path aliases tend to be quite a bit longer than the truncated URL; it's very easy to blow past the allowed number of characters when post title AND post url alias are both included. When that happens, Twitter does NOT compress the long URL with TinyURL; it just truncates, leaving you with a useless post.
For the moment, I've added the update hook and created two parallel replacement keys in the post string: !url will continue to send the short node/$nid based url, while !url-alias will send the fully aliased URL. It's a relatively safe default.
#13
Scratch that. I just added support for automatic generation of the TinyURLs before sending to Twitter. Checked into the -dev release, should be in the next version unless we find problems with it.
If you want to use the shortened URLs, go to the settings and change the default post text from "New Post: !title (!url)" to "New Post: !title !tinyurl". That's the new default, but if you've overridden it in the past you'll need to change it manually.
#14
Comments:
Will this work with the Twitter actions, since that’s how you have to tweet about posts when you’re using a Blog API client?
Will this also work as a token, which seems to be how the title and URL and such are inserted using the Twitter actions module? (In the “Post to Twitter action,” you don’t use !title or !url, but %title and %node_url, so the variable names are even different.)
It would be nice to use other services besides TinyURL, but I guess I can’t quibble.
Thanks!
#15
Just to be clearer about what I'm looking for, I'd be happiest if I could get TinyURL (or other URL shortening services) versions of the Pathauto URL for my posted nodes.
#16
Thanks for noticing that, jaharmi. I'll make sure it gets carried over to the actions as well!
#17
#18
This seems to still be broken for me. I installed the Util.module which allows you to change the weights of installed modules. I pushed Twitter.module to 15 and Twitter_Actions.module to 20 (I know this is extreme but it's just a nice round number after Pathauto.module and Token.module. Seems this still didn't work. Is there anything I have to do after making and saving these changes for them to take effect? Is there a limit to the weight a module can be?
The way I have my Pathauto running is to simply create URLs as "mysite.com/nid" (i.e. without "node/" - making them shorter)
I even tried doing a hard hack of twitter_actions.module.php to line 161 to remove "node/", i.e.
// Node-based variable translation is only available if we have a node.if (isset($node) && is_object($node)) {
$variables = array_merge($variables, array(
'%uid' => $node->uid,
'%node_url' => url($node->nid, array('absolute' => TRUE)),
'%node_type' => node_get_types('name', $node),
'%title' => $node->title,
'%teaser' => $node->teaser,
'%body' => $node->body
)
);
But this is still generating URLs as the same "mysite.com/node/nid" instead of what I want which is "mysite.com/nid".
Have I hacked incorrectly or is there something else I should be changing? Any advice in achieving what I want (whether or not it's a hard hack) would be much appreciated.
Thanks,
Alex
#19
I think the patch above is committed in current dev version, but it still doesnt work for me... I just want to see www.example.com/content/blabla but it appears on twitter as www.example.com/node/number
#20
This is definitely a problem specific to twitter_actions module. The Twitter 2.6 release is going to focus on fixing a number of the issues with twitter.module itself (minor bugs, etc) and the plan for 2.7 is to give twitter_actions some love.
#21
We were able to fix the issue in this thread without patching the module itself by using the Module Weight module. What a tongue twister. This module presents inputs on the main module listing page to alter the modules weight on the fly. I set Twitter to 2 and it resolved the path issue.
http://drupal.org/project/moduleweight
Although I do understand the main point of the patches is so that it may be eventually contributed into the distributed module itself, and this approach does require an additional module to be installed, but we were already using it so no harm no foul. Just thought id post this for anyone that may be interested.