thanks for the module y'all...

I'd like to add /individual the text rendered for each link;
for example 'facebook' would read 'eggonbeagle on facebook'
'youtube' would read 'eggonbeagle on youtube'

can you customize the text rendered for link titles?

i've been able to modify the positioning of the images on the link w css
do i need to modify the follow.module or the install file?

thanks

Comments

q0rban’s picture

Status: Active » Fixed

Hi Jack!

The easiest way I would think is to override theme_follow_link():

Replace the line here with your own customized title:

<?php
    'title' => follow_link_title($link->uid) .' '. $title,
?>

You can look at the code in follow_link_title() to see how to get the username in there.

Hope that was helpful!

ta

q0rban’s picture

Status: Fixed » Postponed (maintainer needs more info)

I just realized you might have been talking about the actual text of the link and not the title attribute of the anchor itself. If so, you'd actually want to change this line instead:

<?php
  return "<a$attributes>$title</a>\n";
?>

You could do something like this instead:

<?php
  $args = array(
    '!name' => theme('username', $account, array('plain' => TRUE)),
    '!title' => $title,
  );
  return "<a$attributes>". t('!name on !title', $args) ."</a>\n";
?>
jackhutton’s picture

thanks for the response:
the second situation is what I'd like to modifly;

(i'm not a php guru.. )
in the folow.module, can i insert static text like 'Eggonbeagle on '
not a field like user.. but leading text...?

would this be right: (probably not.. )

function theme_follow_link($link, $title) {
  $classes = array();
  $classes[] = 'follow-link';
  $classes[] = "follow-link-{$link->name}";
  $classes[] = $link->uid ? 'follow-link-user' : 'follow-link-site';
  $attributes = drupal_attributes(array(
    'class' => implode(' ', $classes),
    'href' => $link->url,
  'title' => follow_link_title($link->uid) .'eggonbeagle on '. $title,
  ));

  return "<a$attributes>$title</a>\n";
}

also.
i notice as i modified the settings in 'Site Configuration' >> 'Performance' >> and enable Block Caching;
rather than return my list of menu items, it would collapse horizontally, onto a single row of text links w. out an image. does this seem odd..or is that affecting something..
i've disabled block caching and the menu renders vertically, with images -

thanks again for your work here..

Jack

q0rban’s picture

Re: block caching: Can you open a separate issue (bug report) for that please? Sounds like it might be a bug, but I need to test it to find out.

Back to your support request:

Copy and paste this function into your template.php file for your theme (without the php tags):

<?php
function phptemplate_follow_link($link, $title) {
  $classes = array();
  $classes[] = 'follow-link';
  $classes[] = "follow-link-{$link->name}";
  $classes[] = $link->uid ? 'follow-link-user' : 'follow-link-site';
  $attributes = drupal_attributes(array(
    'class' => implode(' ', $classes),
    'href' => $link->url,
    'title' => follow_link_title($link->uid) .' '. $title,
  ));

  $args = array(
    '!name' => theme('username', $account, array('plain' => TRUE)),
    '!title' => $title,
  );
  return "<a$attributes>". t('!name on !title', $args) ."</a>\n";
}
?>

You might need to clear the theme registry cache after doing it, and best practice would be to replace phptemplate with the machine name of your theme. E.G., Zen theme would look like this: zen_follow_link()

Hope that helps!

jackhutton’s picture

closer..

added the function to template.php

renamed the function according to your stated parameters..

and it returns 'Anonymous on Facebook'

can i rewrite over the 'username field' w. just actual text: 'eggonbeagle on ' then $title - it will never (in this instance) be used for any other person/link..

thanks - it was fun modifying the templatephp file..thanks for the clear instructions.. & your patience..

q0rban’s picture

Whoops, I forgot a line! :D

<?php
function phptemplate_follow_link($link, $title) {
  $classes = array();
  $classes[] = 'follow-link';
  $classes[] = "follow-link-{$link->name}";
  $classes[] = $link->uid ? 'follow-link-user' : 'follow-link-site';
  $attributes = drupal_attributes(array(
    'class' => implode(' ', $classes),
    'href' => $link->url,
    'title' => follow_link_title($link->uid) .' '. $title,
  ));

  $account = user_load($link->uid);
  $args = array(
    '!name' => theme('username', $account, array('plain' => TRUE)),
    '!title' => $title,
  );
  return "<a$attributes>". t('!name on !title', $args) ."</a>\n";
}
?>
q0rban’s picture

can i rewrite over the 'username field' w. just actual text: 'eggonbeagle on ' then $title - it will never (in this instance) be used for any other person/link..

If you are using the site block instead of the user block, then yes. The code I posted in #6 above won't work for you if that's the case.

<?php
function phptemplate_follow_link($link, $title) {
  $classes = array();
  $classes[] = 'follow-link';
  $classes[] = "follow-link-{$link->name}";
  $classes[] = $link->uid ? 'follow-link-user' : 'follow-link-site';
  $attributes = drupal_attributes(array(
    'class' => implode(' ', $classes),
    'href' => $link->url,
    'title' => follow_link_title($link->uid) .' '. $title,
  ));

  $args = array(
    '!name' => 'eggonbeagle', //Change to what you need here
    '!title' => $title,
  );
  return "<a$attributes>". t('!name on !title', $args) ."</a>\n";
}
?>
jackhutton’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

That did the trick.

What a bright guy. Thank you!!

I'll post the collapsed on cached issue under 'bugs'

Thanks again..

jack