Jump to content


These Forums Are Now Read-Only


For TubePress support, please post a question here or open a support ticket and we will be glad to assist.


Photo

Limiting Characters In Title


  • Please log in to reply
5 replies to this topic

#1 Sam Thornton

Sam Thornton

    Member

  • Members
  • PipPip
  • 19 posts

Posted 13 September 2011 - 09:38 AM

Hi All,

Hopefully someone can help with my initial enquiry.

I am wanting to limit the amount of characters in the title for the video's and then add ... to the end.

An explanation or code-snippet would be much appreciated.

Regards
Sam

#2 eric

eric

    Lead Developer

  • TubePress Staff
  • 2787 posts

Posted 13 September 2011 - 09:41 PM

Hi Sam,

You should be able to do this with a TubePress theme. In your theme's gallery.tpl.php, find the area where the title is displayed. In the default theme, it's around line 44...

<?php echo htmlspecialchars($video->getTitle(), ENT_QUOTES, "UTF-8"); ?>
Simply change this to something like this:

<?php$title = $video->getTitle();$limit = 25;$title = strlen($title > $limit) ? substr($title, 0, 25) . '...' : $title;echo htmlspecialchars($title, ENT_QUOTES, 'UTF-8');?>
Make sense? Let me know if you need help at any step along the way.

#3 Oscar Alvarez

Oscar Alvarez

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 25 September 2011 - 10:18 AM

Hi Sam,

You should be able to do this with a TubePress theme. In your theme's gallery.tpl.php, find the area where the title is displayed. In the default theme, it's around line 44...

<?php echo htmlspecialchars($video->getTitle(), ENT_QUOTES, "UTF-8"); ?>
Simply change this to something like this:

<?php$title = $video->getTitle();$limit = 25;$title = strlen($title > $limit) ? substr($title, 0, 25) . '...' : $title;echo htmlspecialchars($title, ENT_QUOTES, 'UTF-8');?>
Make sense? Let me know if you need help at any step along the way.



I was looking for exactly a way to do this, but it doesn't seem to be working for me anyway. Nothing happens with the title after changing this in the gallery template. Same title with the same amount of characters come out. Am I doing something wrong?

/oscar, sweden

#4 John Hamlin

John Hamlin

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 19 November 2011 - 09:29 PM

error in line 4 of that code ... SHOULD BE:

$title = $video->getTitle();
$limit = 25;
$title = (strlen($title) > $limit) ? substr($title, 0, 25) . '...' : $title /* <-- CORRECTION ON THIS LINE */;
echo htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
?>

#5 whysquare

whysquare

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 16 June 2015 - 07:37 AM

Hi there – I have the opposite request. I would like to use the YouTube Clone theme but INCREASE the title limit – can you please help?



#6 brandon

brandon

    Advanced Member

  • TubePress Staff
  • 1989 posts

Posted 17 June 2015 - 02:48 AM

whysquare,

 

you would make the same modifications but change:

$limit = 25;$title = strlen($title > $limit)

to

$limit = 5;$title = strlen($title < $limit)

Want a faster, more personalized support experience? Open a ticket with us! We will be gradually phasing out forum-based support in favor of a proper ticketing system. Please help us help you!