Closed (fixed)
Project:
Quote
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
24 May 2011 at 12:22 UTC
Updated:
30 Jan 2013 at 20:36 UTC
Hello there,
I'm using Quote with Advanced Forum and have been looking into making a normal webkit CSS button for it, much like seen with the class af-button-small - but I am unsure on how to add it to the code. It might be a relatively newbie question, but I feel like I've tried every angle but it either just disappears so I have to re-enable the module or it bugs out on me.
| Comment | File | Size | Author |
|---|---|---|---|
| quotebutton.PNG | 3.43 KB | trillex |
Comments
Comment #1
Zen commentedSuch customisations are usually accomplished by overriding the theme_quote function if the existing mark-up is not sufficient. Searching for "overriding theme functions" should point you in the right direction ...
-K
Comment #3
sbart76 commentedI guess you need something like:
in function_node_view or function_comment_view.
But it bugs me how to add the 'span' tags around...
Comment #4
Aalandriel commentedI ran into the same issue, trying to override the function from the template files. But since quote_node_view and quote_comment_view are not theme function, you can apparently not override them.
I rewrote the functions - it's working, but my drupal coding skills are almost non-existent and php skills are very rusty (same reason I'm not creating a patch as I haven't a clue how). However it work, so I'm thinking I've done it right.
Comment #5
Darren Shelley commentedI reached this page wanting a span for consistency with Advanced Forum
It would be great to have more power over this through module settings. I've only ever used quote in association with Advanced Forum which does wrap its node links in spans. It is a very common request to be able to place an background image in the button.
Quick and dirty preprocess solution to achieve this:
By the same method you could amend the classes_array to add the class you desire.
When adding a preprocess hook remember to flush the cache.
Comment #6
beefheartfan commentedI couldn't get the code in #5 to work in Drupal 7 using the preprocess hooks in a module. Instead I was able to use hook_node_view_alter() and hook_comment_view_alter(), like so:
Comment #7
topdillon commentedWorks perfectly! Thanks very much.
I am not good at understanding Drupal code yet. Could you possibly show me how to add the private message link to the code? Should it be hyphenated or use underscore or space in some cases. I tried changing the code, but nothing.
Comment #8
topdillon commented@beefheartfan: I spoke too soon. It doesn't work on the comments.
Comment #9
topdillon commentedDarren,
I got your preprocess functions to work by borrowing a line from @beefheartfan's function.
$vars['content']['links']['quote']['#links']['quote']['attributes']['class'] = array('af-button-small');have you an idea how I can get it working for the privatemsg link as well? i.e. What do I replace 'quote' with?
Comment #10
beefheartfan commentedWhoops. The comments function didn't work because I didn't fully remove my original module name from the function name ('styles'). Corrected code below:
Comment #11
beefheartfan commentedI don't have private messaging set up on my forums, so I can't accurately tell you what to replace 'quote' with. But you could add this line within the if statement in the functions to display the entire links array and possibly find what you're looking for:
drupal_set_message('links: <pre>'.print_r($build['links'], TRUE).'</pre>');Comment #12
topdillon commentedThanks b but that showed nothing. Just the title 'Links'.