I cannot figure out how to style the primary links. I am using the Foundation theme to create a custom theme, and I simply want to add a class attribute to the anchor tag of the primary links items. I have looked in the template files, style sheet, phpTemplate handbooks and searched the forums but without any luck. Any ideas? Thanks.

- Tyson

Comments

sin’s picture

Insert 'class="MyClass"' into a link using str_replace function in your theme before primary link output.

But if you want to add the same class to all links it is better to use CSS cascading:

<div class="MyClass">primary links</div>

Css rule for a link

.MyClass a {...}
markhope’s picture

Hi Tyson,

quite a bit of this is covered at http://drupal.org/node/44704

You might get more help there.

This is what I'm using in page.tpl.php but I'm sure there's a cleaner way of including in template.php
It also generates a unique id as well as a class.

<?php if (isset($primary_links)): ?>
<ul id="primary">
<?php 
      $i=1;
      foreach ($primary_links as $link): ?>
<li id="primarynav<?php print t($i) ?>" class="myclass"><?php print $link?></li>
<?php 
      $i++;
      endforeach; ?>
</ul>
<?php endif; ?>

Also look at http://2bits.com/articles/adding-unique-styles-to-primary-and-secondary-...