1

I'm relatively new to ExpressionEngine so please bear with me on this.

I'm trying to add title attributes to the links in my Structure navigation, like this:

<a href="[link]" title="[something]">[page name]</a>

But I'm not having much luck. Here is my {exp:structure:nav} tag:

{exp:structure:nav start_from="/" max_depth="1" include_ul="no" add_unique_ids="entry_id" current_class="font-bold"}

I tried adding in my own custom title parameter but that didn't seem to work either.

This could be a quick fix but I can't see it myself. Any help would be appreciated.


UPDATE: Since I couldn't see a way to add titles through the tag, I went in and edited line 717 in sql.structure.php:

$html .= '<li'. $classes . $ids . '><a href="' . $tree[$i]['uri'] . '" title="' . $title_output .'">' . $title_output .'</a>';

I'm testing it now but it seems to work.

If anyone has a better alternative please feel free to add.

6
  • Tom, can you please provide a code snippet of what the navigation is supposed to look like?
    – kmgdev
    Jan 17 '13 at 17:15
  • like this <a href="[link]" title="[something]">[page name]</a> I'm going to go ahead and use the plugin suggested by @tidy but my ammend to the code above also works.
    – Millard
    Jan 18 '13 at 9:23
  • Ah, I see. Your question made it seem like you were trying to add entry titles, not title attributes. I recommend removing your code hack from your question and posting it as an answer.
    – kmgdev
    Jan 18 '13 at 17:15
  • 1
    I'd consider it redundant to add title attributes to navigation links. If the text of a link is "About Us", you don't really need to add a title of "About Us" to clarify where the link points to. Titles are best used when the link destination is ambiguous, which it usually isn't in site navigation.
    – kmgdev
    Jan 18 '13 at 17:18
  • OK I'll take that into consideration, does it effect SEO in anyway?
    – Millard
    Jan 18 '13 at 18:30
3

As far as I know, the Structure nav tag does not output any title attribute for links.

There is a free third party add-on Structure Entries http://devot-ee.com/add-ons/structure-entries which you could try using to generate your navigation links instead. You specify your own markup for each link, so you could specify the title attribute etc.

Alternatively, you could use javascript to add a title parameter set to the link text into your Structure nav output.

2
  • 1
    Will take a look thanks, any knowledge on just editing structure to pull in the Title tag information from the page name?
    – Millard
    Jan 17 '13 at 14:46
  • No sorry but you could try posting on the Structure support site about that structure.tenderapp.com
    – Janine
    Jan 17 '13 at 16:23
1

If I understand correctly by what 'title' you're trying to output then you'll need to include show_overview="yes".

Overview (Parent) Link show_overview="yes", defaults to no Shows a link at the top of your navigation that links to the current top level page. Use with rename_overview to change the title.

Is that what you were looking for?

1
  • I was looking to include the title in the a tag - <a href="/blog/" title="blog"> like this.
    – Millard
    Jan 17 '13 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.