I made the view reference just the title as the link but the title puts some un-wanted characters in the words if punctuation is used in the views name.

link is

  • Draven's Art

link should be

  • Draven's Art

Is there anyway to fix this?

Comments

Draven_Caine’s picture

hmm it didnt link right

the link reads Draven@#039;s Art
and the link should read Draven's Art as the view is labeled

any way to fix this?

danielb’s picture

testing

Draven's Art

& instead of @

danielb’s picture

Priority: Critical » Normal

Try this in your theme's template.php and replace 'THEME' in the function name with the name of your theme.


<?php

function THEME_viewreference_formatter_plain($element) {
  if (!empty($element['#item']['view_id']) && is_numeric($element['#item']['view_id'])) {
    $view = db_fetch_object(db_query("SELECT name, position, title FROM {viewreference} WHERE view_id = '%d'", $element['#item']['view_id']));
    $view_object = views_get_view($view->name);
    $title = $view_object->get_title() ? $view_object->get_title() : $view->title;
    $output = $title;
  }
  return $output;
}

?>

If this works, I will make this the default in the module.

Draven_Caine’s picture

I placed

<?php

function Vampire_Inc_viewreference_formatter_plain($element) {
  if (!empty($element['#item']['view_id']) && is_numeric($element['#item']['view_id'])) {
    $view = db_fetch_object(db_query("SELECT name, position, title FROM {viewreference} WHERE view_id = '%d'", $element['#item']['view_id']));
    $view_object = views_get_view($view->name);
    $title = $view_object->get_title() ? $view_object->get_title() : $view->title;
    $output = $title;
  }
  return $output;
}

?>

at the very bottom, after the php close tag in my template.php in my theme folder. Vampire_Inc is my theme name. It did not change the odd characters, they are still there also. Ill leave the code in my template.php filew just in case you want to look at it.

danielb’s picture

Did you rebuild your theme registry?
Does this problem happen with the default formatter?

Draven_Caine’s picture

How i know how to rebuild the theme is going to the theme page. i did that plus i went and hit my theme config button.

The display type is title as link.
If i use title (no link) the title prints fine.
So this leads me to understand it has somethng to do with when its a clickable link, because when its just text it prints fine.

This content type is content profile, which is pulled into panels 2.
This issue is also present on the normal content profile view without the panels override.

I have firefox with firebug which i could try to help with, if needed.

danielb’s picture

oh, ok I forgot the link one and the plain one were different...

<?php

function Vampire_Inc_viewreference_formatter_link($element) {
  if (!empty($element['#item']['view_id']) && is_numeric($element['#item']['view_id'])) {
    $view = db_fetch_object(db_query("SELECT name, position, title FROM {viewreference} WHERE view_id = '%d'", $element['#item']['view_id']));
    $view_object = views_get_view($view->name);
    $title = $view_object->get_title() ? $view_object->get_title() : $view->title;
    if (isset($view_object->display[$view->position]->display_options['path']) && !$view_object->disabled) {
      $args = viewreference_get_element_args($element);
      $url_args = implode("/", $args);
      $path = $view_object->display[$view->position]->display_options['path'];
      if ($url_args) {
        $path .= "/". $url_args;
      }
      $output = l($title, $view_object->get_url($args, $path));
    }
    else {
      $output = $title;
    }
  }
  return $output;
}

?>

Draven_Caine’s picture

Nothing has changed as of yet, sorry

display fields menu

  • Label : inline:
  • Teaser : title (link)
  • Full node : title (link)

Title appears as Draven's Art
Title should appear as Draven's Art

If i am missing telling you some info that you need please let me know, sometimes I over look the plain info. Thanks for the great module though, just what we needed.

Draven

/***** EDIT *****/
this is fixed, I just cleared my cache under proformance, and it must have fixed it witht he last template.php code addition.

Many Thanks,
Draven

Draven_Caine’s picture

Status: Active » Fixed
danielb’s picture

Title: Title as a link (clean html) » Remove check_plain() from theme functions
Category: support » task
Status: Fixed » Active

I will add this to be the default code in the module, I got a bit overzealous with the check_plain() in the original

danielb’s picture

Status: Active » Fixed
Draven_Caine’s picture

Thanks,
Thank you for fixing this issue so quick. Its a great additions to our user profiles.

Let me know if i can de-bug more things for you.

Draven.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.