Customizing SMF > Mod Requests
CoNSistent headline mod - anyone?
(1/1)
destalk:
Hi all. This is carried on from a feature request here.
It would be nice to have an option in Admin settings so that posters can't start thread headings in ALL CAPS, or MiX aNd maTCh.
In fact it would be nice to have a few extra options too. On some of my SMF forums I would like to have all thread headers to be Initial Cap For Each Word, on others just an initial cap for the Beginning of a sentence would be preferable, on others it doesn't really matter.
Some people have pointed out that in some cases it would be desirable to have a mix of upper and lower case letters. For example JPEG, phpBB and so on. Would it then be possible to have a method for the administrator to add and exclude certain combinations of letters from the filter.
Anyone fancy a pop at this? :)
Oldiesmann:
Here's a simple version right now. If there's enough interest, I can package it into a mod later...
Sources/Post.php
Find
--- Code: --- // Hack to make it so 񏋤... can't happen.
$_POST['subject'] = preg_replace('~&#\d+$~', '', $_POST['subject']);
--- End code ---
Add after that
--- Code: --- // Fix casing on subjects so SHOUTING and MixeD CAsE SubJectS don't work...
$boards_first_cap = array('1', '2', '3', ...);
$words_to_exclude = array('SMF', 'phpBB', 'JPEG', ...);
if(in_array($board, $boards_first_cap))
{
$_POST['subject'] = ucfirst(strtolower($_POST['subject']));
foreach($words_to_exclude AS $word)
{
$temp_array[] = ucfirst(strtolower($word));
}
str_replace($temp_array, $words_to_exclude, $_POST['subject']);
}
else
{
$_POST['subject'] = ucwords(strtolower($_POST['subject']));
foreach($words_to_exclude AS $word)
{
$temp_array[] = ucwords(strtolower($_POST['subject']));
}
str_replace($temp_array, $words_to_exclude, $_POST['subject']);
}
--- End code ---
That's about the easiest way I can think of to do this. It's also quite sneaky, because the user thinks they're getting away with something, but when they actually post, they find out otherwise.
$board_first_cap is an array containing the board IDs of all the boards where you want to capitalize the first letter of the subject.
$words_to_exclude is (of course) an array of words to exclude from this.
If you want to exclude boards from having their subjects messed with altogether, then make the following changes:
Add another array called $board_no_touch, containing the IDs for the boards you want to exclude.
Change the else to elseif(!in_array($board, $board_no_touch))
destalk:
Thanks Oldiesmann. I'll give that a try and see how it goes.
Much appreciated. :)
Navigation
[0] Message Index
Go to full version