By designwork on
Hi
I´m trying to write a module with a custom link funktion but i dont know how to make it in 5.1
I tryed this way.
/**
* Implementation of hook_link()
*/
function myfile_link($type, $node = NULL, $teaser = FALSE) {
$links = array();
if ($type == 'node' && isset($node->myfile) && $teaser == TRUE) {
$links[] = theme('myfile_links', $node);
}
return $links;
}
function theme_myfile_links($node) {
$link = '<img src="/' . drupal_get_path('module', 'mymodule') . '/lock.png" alt="[P]" />';
return $link;
}
But the theme.inc can not use the array. My aim is i want to have a special image in all links from my module....
Dirk
Comments
Try this
Use the Drupal API site to find info on hooks, functions, etc.: http://api.drupal.org/api/5/function/hook_link
----
http://eUploads.com
no result
Hi Michael M.,
unfourtanatly it does not work but i dont know why....
I tryed some of the exampels but nothing worked out.
Any more idea?
Basic debugging
I'd say that the easiest place to start with this is to verify if both of these functions are being called or not.
Simply echoing text from within the function will let you know if they are working on some level or not. They you can figure out why the png isn't popping up after you know that the functions are otherwise working as they should.
Mike
--
OpenConcept | WLP | ox.ca
OO | Jean Crowder, MP
working know, thanks for help
Hi Mike,
thanks for the help. the funktion is working now. problem was the if statement.
old: if ($type == 'node' && isset($node->myfile) && $teaser == TRUE)
But every node is allways myfile, just with yes or no
new: if ($type == 'node' && $node->myfile && $teaser == TRUE)
This was the hole problem....
Dirk
You can try hook_link_alter or modify the css
To fix your aim, just try hook_link_alter. Code like below:
Or, the most fast way is modify the css file, just add lines like below:
ul.links li {
background-image:lock.png;/** you must specify your png file path to work properly */
padding-left:10px; /** you must specify the width to you image width */
}
Good luck. And if this help you , please tell me, Thanks.