Ok so I use a phptemplate theme, and I have all my primary links set up. But I want one - just one - of them to be red. I tried using <font color="#FF0000"></font> tags, but then my link was still grey, and it showed up in the top menu as <font color="#FF0000">HELP</font>.

So... can I actually change the colour of one link? For that matter, I always planned on substituting <img> tags for the text links, but will that work either?

Comments

heine’s picture

Either assign an ID to the link and style it in style.css or use an inline style:

<a id="your_id" ...>
<a s tyle="color: #FF0000;" ..... >

(space in style to escape the filter)

edit to add: you need to edit the template in page.tpl.php. What theme do you use?
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

canadrian’s picture

Thanks for the super-quick response!

I use a modified version of the box_grey theme. Do I need to edit the page.tpl.php if I use the inline style? I mean, do I really have to edit global stylesheets to make one word red?

Edit: Oh, hey, just realized... where would I put those tags anyway? I get a list of text boxes for text and urls, that's it. I guess I can't really modify the code then...

----------
"Being tired is like playing mind games with some of the pieces missing."
- Canadrian

I am a proud member of the ElectricTeaParty.net online community.

heine’s picture

The problem is that phptemplates assemble the links from a url, text and description. In the process all tags are escaped, so they'll show up in the rendered page.

If you want to style the active link you can use the class selector .active (a.active {color: red;}). If you want to style an arbitrary link it's more difficult. You need to edit the file page.tpl.php in your themes/[your theme] directory.

In box_grey the code to print $primary_links is

<?php if (count($primary_links)) : ?>
  <ul id="primary">
  <?php foreach ($primary_links as $link): ?>
    <li><?php print $link?></li>
  <?php endforeach; ?>
</ul>
<?php endif; ?>

$primary_links is an array with the structure [url] => <a href="/..."...>text</a>. Suppose you have the following primary links:

url blog with text 'Blogs' and
url node/5 with the text 'About'

these can be accessed / printed with

 print $primary_links['blog'];
 print $primary_links['node/5'];

This means that if you want to style the link to node/5 differently you can replace the primary link printing in box_grey with the following:

<?php if (count($primary_links)) : ?>
  <ul id="primary">        
    <?php foreach ($primary_links as $key => $link):?>     
      <?php if ($key == 'node/5'): ?>
        <li id="the-one"><?php print $link; ?></li>
      <?php else: ?>
        <li><?php print $link; ?></li>
      <?php endif; ?>      
    <?php endforeach; ?>
  </ul>
<?php endif; ?>

Then in style.css add

li#the-one a {
 color: red; 
}

Note: code above is from the standard box_grey theme.

edit: fixed url, spelling
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.