Hi, thanks for the module. I've got everything up and running and I have my jump menu displaying a selection populated from a custom view, embedded directly into a template file - thanks to the code in supplied in this thread.

I'm trying to limit the number of characters displayed in the titles of my dropdown selection - as it's breaking my design. I have tried several methods to achieve this, but with no success. Here's what I tried:

  • Trim the Title text in views settings - this works in the views preview but has no effect in my jump menu.
  • Create a custom views template - trying to truncate the title from within the veiws template didn't work either.
  • Tried to apply truncate directly to code suplied in thread mentioned above - it has no effect.

Asides from changing my design to accommodate the jump menu, I've run out of ideas. Can anyone point me in the right direction?

Thanks in advance.

Comments

marcp’s picture

Since you're already using some custom code to fill the jump menu, you may as well stick the code in there. If you're using that same code you linked to, it's going to give you the node title.

Can you print out (use dpm() from devel) the $node variable within that loop so you can see what else is in there? I'm guessing that you just need to find the right field from your view to print, but I haven't looked closely at this code in a while.

Using substr() on $node->node_title ought to work too. Try something like substr($node->node_title, 0, 25).

random_tom’s picture

Thank you. That's done the trick, although I opted for using truncate_utf8() so I could include an ellipsis - I checked the substr() docs and couldn't see an obvious solution for adding this. Here's what I used:

  $view = views_get_view('your_view_here');
  $view->preview();
  foreach ($view->result as $node) {
	$options['node/' . $node->nid] = truncate_utf8($node->node_title, 21, TRUE, TRUE);
  }

  print jump_quickly($options);

This saves me the hassle/overhead of installing CTools just to get the Jump Menu option. Appreciated.

random_tom’s picture

Status: Active » Fixed

I should have marked this as fixed in my last post.

Status: Fixed » Closed (fixed)

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

insomoz’s picture

Version: 6.x-1.1 » 5.x-1.1

I'm confused by the Views code, as I don't know code very well.

In my block I have terms instead of views.
Like

<?php
  print jump_quickly(7, 'taxo');
?>

Where 7 is the category of the Taxonomy Term that I require.
Where do I place code to truncuate the title as its also ruining my design.

insomoz’s picture

Status: Closed (fixed) » Active

have reopened to find solution for beginner.