Currently I'm calling the primary nav in my theme like so: 'links primary-links')) ?>
But when it's displayed Drupal is assigning what appear to be random classes to the list items, like:
What's the easiest way to go about applying the desired css to these links? Is there a way to tell Drupal what class to assign?
Thanks, Jeremy _________________________________________________________________ See what people are saying about Windows Live. Check out featured posts. http://www.windowslive.com/connect?ocid=TXT_TAGLM_WL_connect2_082008
seems much of my code got cut, let's try that again:
Currently I'm calling the primary nav in my theme like so:
print theme('links', $primary_links, array('class' => 'links primary-links'))
But when it's displayed Drupal is assigning what appear to be random classes to the list items, like:
li class="menu-144
What's the easiest way to go about applying the desired css to these links? Is there a way to tell Drupal what class to assign?
Thanks, Jeremy
_________________________________________________________________ Get thousands of games on your PC, your mobile phone, and the web with Windows®. http://clk.atdmt.com/MRT/go/108588800/direct/01/
On Aug 27, 2008, at 3:22 PM, Jeremy Weiss wrote:
Currently I'm calling the primary nav in my theme like so:
print theme('links', $primary_links, array('class' => 'links primary- links'))
But when it's displayed Drupal is assigning what appear to be random classes to the list items, like:
li class="menu-144
What's the easiest way to go about applying the desired css to these links? Is there a way to tell Drupal what class to assign?
If I'm reading the theme_links() source code correctly, those class names are coming from the keys in the $primary_links array. Try printing out the $primary_links array and see what it looks like -- I like to install Devel module and then do something like
dpm($primary_links);
or if that doesn't work, try using dprint_r($primary_links) or drupal_set_message(dprint_r($primary_links, TRUE))
If I'm right, you'll find your "apparently random" class names as keys in that array.
As for changing the classes, one way would be to fiddle around with the $primary_links array before you call the theming function. Another way, which might be better, is to write a custom theming function for your links. You can either call that function directly from your theme or give it a name like phptemplate_links() or yourthemenamehere_links() to override Drupal's default definition of theme_links().
You can find theme_links() itself in includes/themes.inc if you want to steal ideas from it.
mechfish