Advertisement:

Author Topic: How to increase topic tilte/subject length?  (Read 822 times)

Offline waplist

  • Semi-Newbie
  • *
  • Posts: 60
How to increase topic tilte/subject length?
« on: April 04, 2017, 01:27:26 AM »
Hello,
         I tried to create new topic but i think smf doesnt allow title longer titles . there is also no setting to change that in smf.  Help on this thank you

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 51,265
Re: How to increase topic tilte/subject length?
« Reply #1 on: April 04, 2017, 05:07:29 AM »
are you actually using SMF 2.1?

Offline waplist

  • Semi-Newbie
  • *
  • Posts: 60
Re: How to increase topic tilte/subject length?
« Reply #2 on: April 04, 2017, 05:39:29 AM »
Sorry actually its 2.0.13.
« Last Edit: April 04, 2017, 05:52:58 AM by waplist »

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,498
  • Gender: Male
    • Kindred-999 on GitHub
Re: How to increase topic tilte/subject length?
« Reply #3 on: April 04, 2017, 10:18:06 AM »
And, the next question is..  why?

Why do you think you need a topic longer than 80 characters?

In almost every case, when someone asks for this, they are attempting to "abuse" the system for a reason that is not actually necessary or even good.

And, as to why it's not a setting... you would gave to change a source file, a template file and the database
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline shadav

  • Jr. Member
  • **
  • Posts: 205
  • Gender: Female
Re: How to increase topic tilte/subject length?
« Reply #4 on: September 08, 2019, 09:48:12 PM »
sorry to bump an old topic, and hijack it
but I have the same question....
2.0.15
I need to lengthen the topic title
I post a lot of article type posts and have run into the issue of the title character limit, can't find a setting in the admin to change it
I would think that 120 would be more than enough

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,746
  • Master of BBC Abuse
Re: How to increase topic tilte/subject length?
« Reply #5 on: September 08, 2019, 10:02:13 PM »
Shouldn't need a database change. It's already varchar(255) which is more than adequate.

The template code is here, in Post.template.php:

Code: [Select]
// Now show the subject box for this post.
echo '
<dt>
<span', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</span>
</dt>
<dd>
<input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text" />

Where the size is just the visible width, and the max length is the critical part. The database would allow you to set 255 here if you were that bonkers.

The trickier part is Sources/Post.php (because Sources is always a tad gnarly IME):

Code: [Select]
// Make sure the subject isn't too long - taking into account special characters.
if ($smcFunc['strlen']($form_subject) > 100)
$form_subject = $smcFunc['substr']($form_subject, 0, 100);

Which is obviously happy with 100 characters, but will truncate anything over that. It should, I think, be safe to increase that to 120 if you need that many. At which point Arantor will probably pop up and tell me about all sorts of dire things that will happen.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,605
    • StoryBB/StoryBB on GitHub
Re: How to increase topic tilte/subject length?
« Reply #6 on: September 09, 2019, 02:28:52 AM »
As requested.

255 is only enough if you don’t have special characters in the subject. The relationship between the logical length of the string and the physical is tenuous at best.

A " will consume 6 out of the 255 but only 1 out of the 100/120. Emojis are the worst though, they usually only count as 1 out of the 100/120 but up to 9 out of the 255, each.

That’s why the disjoint, trying to cover as many cases of space consumption as possible, or at least, as was likely at the time (as those numbers were set long before the current emoji even existed)

The only problem is that it will truncate somewhat spuriously in this case, either with an error or more likely no error and then you just get a mangled title. Or it gets mangled later by the forced “Re:” stuff that is normally covered but suddenly now might not be.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,746
  • Master of BBC Abuse
Re: How to increase topic tilte/subject length?
« Reply #7 on: September 09, 2019, 02:42:54 AM »
Learn something every day. Ok, do you think it would be safe to increase it to 100, to match the truncation limit in Post.php?

Assuming that whoever was using it had enough sense to not fill the subject up with smileys and special ZOMG characters.

Which some clown is bound to do sooner or later, but you can always just point at them and start giggling.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,605
    • StoryBB/StoryBB on GitHub
Re: How to increase topic tilte/subject length?
« Reply #8 on: September 09, 2019, 02:54:26 AM »
Even 120 is safe as long as the subject isn’t full of ', ", <, >, & or emojis. These are all characters that are stored in an encoded format. A few is ok, a lot breaks it.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,746
  • Master of BBC Abuse
Re: How to increase topic tilte/subject length?
« Reply #9 on: September 09, 2019, 03:18:32 AM »
Caveat scriptor, then. :)

I suppose it would technically be possible to break things even with the default 80 character limit, if you specifically set out to do that just to prove a point.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,605
    • StoryBB/StoryBB on GitHub
Re: How to increase topic tilte/subject length?
« Reply #10 on: September 09, 2019, 03:35:07 AM »
Yup, and it has been observed, but generally it isn’t usually a problem, because most posts don’t trip over this, because topic titles that are a mass of specific punctuation are annoying as are topics that are just emoji.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline shadav

  • Jr. Member
  • **
  • Posts: 205
  • Gender: Female
Re: How to increase topic tilte/subject length?
« Reply #11 on: September 09, 2019, 12:18:09 PM »
thank you both and interesting info
hopefully smilies and whatnots won't be an issue

so then am I correct in that I changed, the 80's to 120's
Code: [Select]
<input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="120" maxlength="120" class="input_text" />
and that I changed the 100's to 120's

Code: [Select]
// Make sure the subject isn't too long - taking into account special characters.
if ($smcFunc['strlen']($form_subject) > 120)
$form_subject = $smcFunc['substr']($form_subject, 0, 120);

it seems to work so far....

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,746
  • Master of BBC Abuse
Re: How to increase topic tilte/subject length?
« Reply #12 on: September 09, 2019, 05:19:31 PM »
Yep. That should be all it needs.