Extend Character Count for Subject Line

Started by jawad96, October 22, 2014, 07:03:54 AM

Previous topic - Next topic

jawad96

Hi all,

I'm on the latest 2.0.9 version. I've searched around and found a couple of threads related to this, however found them slightly confusing - some required database change and edit in the theme or something. Currently I am using a custom theme.

I was wondering how I can include more characters in the subject line when creating a thread as it is currently limited to 81 I think? This should reflect in all the posts below it and when viewing it in the board.

Any mods available or anything?

Thanks!

Arantor

They do generally require changing the database structure itself to make it work depending on language used.

Also not recommended for performance reasons.

Kindred

As Arantor says -- this would require changing the database, changing the template(s) and possible changing some of the source file(s).

*AND* is not recommended...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Oh, it definitely requires source changes.

jawad96

Despite these negative effects, should I wish to go down the route, any advice on doing this?  ;D

Arantor

When you have the project manager and one of the world's most foremost experts on SMF (and so modest ;D) telling you it's a bad idea... you pretty much would need to have a fairly exceptional reason to do it, not to mention providing more details about the circumstances, configuration and whatnot that you're using... ;)

margarett

Not trying to do the "good cop" thing here but I don't see why not give it away.
In fact, this was debated and solutions given in the past (which, as always happens to me, I can't find off-hand :P )

The "subject" field in the table is a VARCHAR(255). Depending on the language you're using, each character can actually be *some* characters long, thus a safe limit of 1/3 of the field size exists.
To change the column type to a different type (bigger) is actually a bad ideas as you are being told. Yet, if you only use English and your members don't use strange characters, I don't see why not :)

Apart, of course, from breaking your layout completely :P (see attached image)

In short: edit Post.template.php and increase the field's "maxsize" property. Edit Post.php and search for instances of "$smcFunc['strlen']", there you'll see a comparison of the subject with 100. Increase 100 to the number you want (don't go above 255 in any circumstance and even 200 should cause you problems with strange characters...)

Keep a copy of your original files, you will want to have them back ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Arantor

QuoteThe "subject" field in the table is a VARCHAR(255). Depending on the language you're using, each character can actually be *some* characters long, thus a safe limit of 1/3 of the field size exists.

Here's the principle problem.

Going above VARCHAR(255) has some very interesting characteristics. But also, some characters take *more* than three bytes for this to be a thing. So 255 is a generally - but not totally - safe limit and it's quite possible to overflow beyond 255 chars even without extending beyond 80 "characters".

The reason this is problematic is because it's when it's going to cross the byte threshold for the internalised length handling in MySQL and some versions do not handle this properly.

jawad96

Thank you for your assistance. I couldn't get it to work though, however I saw this:

It is currently set to a max of 80.  I believe your can change it in /Themes/default/MessageIndex.template.php.

Code: [Select]
<input type="text" name="subject" value="\' + subject + \'" size="60" style="width: 99%;"  maxlength="80"

Change maxlength="80" to whatever value you want.

Also you will need to change the same information in /Themes/default/Display.template.php

Code: [Select]
<input type="text" name="subject" value="%subject%" size="60" style="width: 99%;"  maxlength="80"


I was wondering if this does any damage and has the same end result? It has worked for me

Thanks

jawad96

Actually, I'm not even sure what it does - it seems whenever I have reached to the end of the subject bar, it doesn't let me type anymore. However, I can go back to the beginning and start writing behind what I had written and it will type more characters?

Kindred

Changing it in the template will not result in the desired change.   We've alreayd stated that it will involve template files, source files and database

You have not answered WHY you think you need to do this...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Vince S

I am buying in here as I would really like to see this happen, if it is a possible practical reality - with full deference to the points Arantor makes as, when all is said and done, we CAN live with the restriction (as we are). But it is a regular source of frustration to me and I would rather not have to.

Starting with some facts. We ACTUALLY have 76 characters to use as a topic title as 4 are reserved for "Re: " - check the maxxed out title of this post. That is an absolute pain in the ring for me as I am often arranging physical events and want the topic title to tell people all the critical data, basically name of the event, its location, day & date/s, departure point and time. It is a rare event indeed that this fits in the topic header without some crunching.

The other aspect of this general topic is that we have been using widescreens for nearly a decade now and it is just wasted screen space having a topic length lucky to be 1/4 the width of it. For my particular use it would be sooo nice to have 150 characters. But equally, on the screen width logic, 256 characters would be a pretty tidy compromise for typical theme layouts. the issue raised of "some characters are multiple characters long" should be a language pack issue. For Unicode they are ONE character long, so let's deal with that - even if it is a user chosen field length choice that they take the risk on truncations

With long topics the practical reality option to get in effect tweeting happening via a topic response being the next level back from a Quick Reply.

Increasing topic length is a natural progression issue that should just drop on the radar in a normal development cycle as it is an idea that is well past its time but hasn't happened. If there are real impediments to that going ahead then fair enough, it shouldn't get e guernsey. I am well aware of the competing issues that could arise, but really - is it that hard? (um, "yes" is a perfectly acceptable answer, if true!)
Try figuring out where all this is going to keep coming from: Millionaire Baby? Or just pass me a beer and we'll sort it, thank you.....

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

QuoteBut equally, on the screen width logic, 256 characters would be a pretty tidy compromise for typical theme layouts

Actually it wouldn't from a technical standpoint as already explained. I will also point out a growing trend towards mobile use where shorter is more advisable for the obvious reason.

Quotethe issue raised of "some characters are multiple characters long" should be a language pack issue. For Unicode they are ONE character long

No, they're not. The problem is not strictly characters in this situation. It is partially about actual byte count too.

And that's even before we get anywhere near the thorny issue of 'the various exciting characters that get transcoded to entity form'.

QuoteIncreasing topic length is a natural progression issue that should just drop on the radar in a normal development cycle

No, it isn't.

Vince S

OK, I "get" and accept those points. What about this, is it something I could do too (using 150 in lieu of 80) or is it setting up for a train wreck somewhere?:

Quote from: jawad96 on October 22, 2014, 07:51:08 PM
It is currently set to a max of 80.  I believe your can change it in /Themes/default/MessageIndex.template.php.

Code: [Select]
<input type="text" name="subject" value="\' + subject + \'" size="60" style="width: 99%;"  maxlength="80"

Change maxlength="80" to whatever value you want.

Also you will need to change the same information in /Themes/default/Display.template.php

Code: [Select]
<input type="text" name="subject" value="%subject%" size="60" style="width: 99%;"  maxlength="80"

I was wondering if this does any damage and has the same end result? It has worked for me
Try figuring out where all this is going to keep coming from: Millionaire Baby? Or just pass me a beer and we'll sort it, thank you.....

Arantor

As has already been said in this thread, literally just changing the template will not solve the issue; the other limits elsewhere will still be applied.

Vince S

So this is bs:?
Quote from: jawad96 on October 22, 2014, 07:51:08 PM
It has worked for me

Perhaps Jawad would be kind enough to elaborate on this comment - perhaps even send a link to a topic with a long subject and dummy or real posts showing it was preserved....?
Try figuring out where all this is going to keep coming from: Millionaire Baby? Or just pass me a beer and we'll sort it, thank you.....

Arantor

No, it's just that it doesn't work quite how you might imagine.

The limit in the browser is 80 characters. There is another check elsewhere in the source that extends it to 100 characters to allow for certain non-Unicode expansions. I suspect jawad has managed to do something like 90 characters which doesn't require changing the other checks.

Additionally, the other checks treat encoded entities less like multi-characters and more like their actual characters so 100 'characters' as $smcFunc['strlen'] calculcates may not be the 100 'characters' you were thinking of.

It's actually ridiculously complicated in terms of code path.

jawad96

Hi again,

Sorry Vince, I commented immediately after that
Quote from: jawad96 on October 22, 2014, 07:56:21 PMActually, I'm not even sure what it does

It looked like it had no effect..? Not sure.

The reason I need more characters in the subject line is so I can add more information. Majority of the times 80 characters is too short, so if there was an easy method to change it I was planning to do so. But looks like the unanimous vote to do this from a technical stance, is a big no.

I'm sure there are other users who may like to see this implemented as I have seen other threads re this, however none had any solution which were simple step by step instructions or actually even worked.

Kindred

jawad96,

why is 80 characters too short?   What specifically are you putting in to the title?
Vince has his edge case where he wants to put all of the details about an event into the title (which I would argue is silly -- you put the event title into the title and the details go into the body)

so, what case do you have for needing information that takes more than 80 characters? What information are you trying to cram in there?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: