By seaneffel on
I would like to re-order the links that appear at the bottom of the content nodes, the "read more" and "email this page" and "unsubscribe" stuff.
Currently, there are a couple of links in the way of the "read more" link, which on our site is more important than the others.
I would also like to shorten the vocabulary on some of the links, so "email this page" becomes "email" or some such nonsense.
View my page so you can see what I mean: http://www.cctvcambridge.org
Does anyone have any tips? Thanks!
Sean
Comments
Override theme_links in your
Override theme_links in your theme's template.php or smartytemplate.php (PHPTemplate and Smarty theme engines, respectively).
Initially just copy the current code to a custom function named {theme_name_here}_links.
http://drupaldocs.org/api/head/function/theme_links
(code in template.php or smartytemplate.php -- depending on your theme-engine -- within your theme directory)
You can put your own sorting logic in there.
I understand how to copy and
I understand how to copy and paste the code, but not sure where that code should be stuck in my template files. I'm using xtemplate.
Also, how do I set parameters for sorting the links - I don't speak PHP!
Thanks for your help so far!
Sean
Ordering links with theme_links in Drupal 5
From what I can work out in Drupal 5 you can use theme_links. Can anyone give an example of the php and logic you could use to reorder the links?
Would be really, really helpful!!
Changing the vocabulary is
Changing the vocabulary is pretty easy with the locale module. Here is a nice post that explains it in detail:
http://drupal.org/node/43791#comment-81553
Thanks!
Thanks for this link, it hit the spot!
You're welcome:-)
You're welcome:-)
Links array re-ordering
I ended up here while doing a search as I wanted to achieve the exact same thing. However, the solution given above doesn't fit what I want.
Here's the solution I came up with (quite simple, yet had to dig into how PHP deals with arrays):
Woohoo! My first post here finally!
--
Jhoom.com
Time for a flexible $links module...
This is a bone of contention with regards to Drupal flexibility and user friendliness with me. This page reads like hieroglyphics to anyone who's not a coder. There should be a module that simply allows us to drag and drop reorder and rename the links, assign icons, etc. at the bottom of any node, specific to the theme that I'm in/setting up at the moment.
I know it would be one incredibly challenging module to write, but I know coders that eat that stuff like a good chess game, so I'm throwing down the challenge. Any takers?
Nice
Nice snippet of code - very useful GuruJi! I've modified it slightly to be a little easier to customize...
This should work in Drupal 5.x - simply rename the function from "yourtheme_links" and paste in your template.php file.
add any keys for links you want to appear first in a list. For myself, I used
"$searchkeys = array('comment_add', 'comment_forbidden');"
Themeable in Drupal 6?
Am I right, did I read that this is now handled on the theme layer by Drupal 6?
Slightly better version
Here's a slightly better and more flexible version of the above code:
Reorder Function:
Usage:
need a conditional statement in there
Great snippett. However, you need a conditional statement in the phptemplate_links function as follows:
Otherwise, if the node/comment doesn't have links the reorder_links function will throw an error.
Mike
Veneer | Crack-proof Creative
http://www.veneerstudio.com
Civicsolar
http://www.civicsolar.com
this worked - thanks!
This worked. I just pasted the function into my template.php and then added this to my theme_links function (I'm using the permalink and sharethis modules):
Giddyup!
It took me a while to understand where to put what (especially where to insert my keys) but in the end it worked. :)
To other visitors as thick as myself: put the keys (which in this case is the same as the css class, so easy to find) of the list items where 'first-link', 'second-link', 'last-link' are in the example.
Thanks a lot to all contributors to solve this problem, and of course especially to Linxor.
Thank you.
This has worked nicely for me. (I added it to template.php, but would have liked to have it live somewhere else, to help prevent accidental hammering)
hook_link_alter() is an alter-native
The same reordering can be done also in hook_link_alter(). It is easier to reorder in hook_link_alter() if you want the same order of links in multiple themes and/or if you do not want to implement new theme (or change an existing one).
Hi,Could with this solution
Hi,
Could with this solution also the $links stuff be placed on more than one line:
So you get:
Thanks a lot in advance for your reply!
greetings,
Martijn
You could just use css to put
You could just use css to put these on multiple lines. Something like: li.links {float:left} for all of them or clear:right to break it spmewhere specific.
Edit order without editing theme
Here is how:
This being Drupal, there is
This being Drupal, there is now a module for that 8o)
http://drupal.org/project/linkweights
d7 slightly different syntax
you could tweak this or the reorder_links function - this is probably the best place though