Title Control

Title Control 1.7

No permission to download
Title Control 1.2
I set 'Maximum Length = 150' in Option, when I creat a thread with > 100 characters
"Please enter a value using 100 characters or fewer."
 
I'm sorry, but I failed to correctly test the 150 character limit. XenForo does some extra checking on the title length and it's not going to be possible to exceed the 100 character title limit without other code modifications.
 
Last edited:
You could change it inside the thread datawriter;)
Rich (BB code):
        'title'  => array('type' => self::TYPE_STRING, 'required' => true, 'maxLength' => 100,
           'verification' => array('$this', '_verifyTitle'), 'requiredError' => 'please_enter_valid_title'
         ),

http://xenforo.com/community/threads/how-to-make-changes-to-the-thread-title.62035/#post-658745


AND you also need to have the database limit in mind! If you want more then 150, you need to change the database structure too!
 
Last edited:
I updated this to 1.2 yesterday and 1.3 today. :confused:

Versions 1.0 and 1.1 did not come with any TitleControl.php file - we had to add it manually. Apparently, versions 1.2 and 1.3 now come with a TitleControl.php file which overwrites the existing one (not necessarily a bad thing *if* we know it's gonna happen) and contains *a lot* of code in it. Since I didn't see any explanation of this in either the Overview or Discussion I'm unclear on what the new code does or how to use it. I ended up reverting to my previous TitleControl.php file but some guidance here might be helpful.
 
Versions 1.0 and 1.1 did not come with any TitleControl.php file...

My apology, The Sandman.

I forgot to delete my personal TitleControl.php file. I'll re-upload v1.3 with that file removed.

Thank you for bringing this to my attention.
 
Hi time,

Here's the code to make every character after a period uppercase.

PHP:
<?php

// get title
$title = $this->get('title');    

// make every character after a period uppercase
$title = preg_replace_callback('/[.!?].*?\w/', create_function('$matches', 'return strtoupper($matches[0]);'),$title);

// set title
$this->set('title', $title);

?>
 
Hi time,

Here's the code to make every character after a period uppercase.

PHP:
<?php

// get title
$title = $this->get('title');   

// make every character after a period uppercase
$title = preg_replace_callback('/[.!?].*?\w/', create_function('$matches', 'return strtoupper($matches[0]);'),$title);

// set title
$this->set('title', $title);

?>
Thanks, AndyB.
But it's not working with UTF-8 charactors, example : à, è, ì, ò, ù,....
 
Original title : "Mùa đông bạn thích ấm hay lạnh?ấm"
Returned title : "Mùa đông bạn thích ấm hay lạnh?m"
Use AndyB code with :
PHP:
<?php

// get title
$title = $this->get('title');

$title = preg_replace_callback(
    '/[.!?].*?\w/u',
    function($matches)
    {
        return mb_convert_case($matches[0], MB_CASE_TITLE, "UTF-8");
    },
$title);
 
// set title
$this->set('title', $title);
 
?>
And work perfectly.
Thanks so much, @AndyB
 
Last edited:
For work with non-latin characters (multibyte) in UTF-8 need replace 2 strings in library/Andy/TitleControl/DataWriter/Discussion/Thread.php.

28:
Code:
$title = substr($title, 0, $maxLength);
replace with:
Code:
$title = mb_substr($title, 0, $maxLength,'UTF-8');

37:
Code:
$title = ucfirst($title);
replace with:
Code:
$title = mb_strtoupper(mb_substr($title, 0, 1, 'UTF-8'), 'UTF-8') . mb_substr($title, 1, mb_strlen($title), 'UTF-8');
 
Can You add conditions: If title = "xxxxx" then title = "yyyyy" else if ..... ?
In admin as list?
 
Last edited:
Great addon, thanks!!

Additionaly: I would like certain words always to start with a uppercase. For example xenforo, should always be written as Xenforo. How could I do this with TitleControl.php?

Thanks!
 
@AndyB I'm assuming this is only changing the max length of thread titles? Or can it change the forum title length too? If not, how should I go about that?

Thanks
 
Hi, I install the addon just like you said but it doesn't allow me to change the Maximum Length, it goes back to 100
 
Top Bottom