Set max subject length in admin screens

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Get Involved
Locked
nickn77
Registered User
Posts: 7
Joined: Sat Nov 27, 2010 3:32 am

Set max subject length in admin screens

Post by nickn77 » Sat Nov 27, 2010 4:20 am

...without having to edit html and php templates.

The default max subject length is something like 60 which is really pretty short. In order to change that you have to edit a number of source files per:

http://www.phpbb.com/community/viewtopi ... 2&t=999995

It would be very useful to have a setting in the admin screens to change that without having to make code edits that have to be set again each time you upgrade.

Ather
Registered User
Posts: 1032
Joined: Fri May 08, 2009 9:42 am
Location: Kingdom of Bahrain
Name: Ather Akber

Re: Set max subject length in admin screens

Post by Ather » Sat Nov 27, 2010 6:55 am

Ok, Here are the instructions required for you to edit it from the ACP, but you still have to do some file editing 1 last time :mrgreen:

Open:
includes/acp/acp_board.php
Find:

Code: Select all

'warnings_expire_days'    => array('lang' => 'WARNINGS_EXPIRE',        'validate' => 'int',    'type' => 'text:3:4', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
'legend3'                    => 'ACP_SUBMIT_CHANGES',
 
Add After:

Code: Select all

// subject length in ACP - Ather    
    'legend3'            => 'SL_SETTINGS',
    'SL'      => array('lang' => 'SL',      'validate' => 'int',   'type' => 'text:4:4', 'explain' => false),
// subject length in ACP - Ather  
Open:
language/en/acp/board.php
Find:

Code: Select all

 'BOARD_PM_EXPLAIN'         => 'Enable or disable private messaging for all users.', 
Add After:

Code: Select all

// subject length in ACP - Ather
'SL' => 'Subject Length',
// subject length in ACP - Ather
 
Open:
language/en/acp/common.php
Find:

Code: Select all

 'ACP_ADMINISTRATORS'      => 'Administrators', 
Add After:

Code: Select all

// subject length in ACP - Ather
'SL_SETTINGS' => 'Subject Length Settings',
// subject length in ACP - Ather
 
Open:
includes/functions.php
Find:

Code: Select all

$template->assign_vars(array(
        'SITENAME'                        => $config['sitename'],
 
Add After:

Code: Select all

// subject length in ACP - Ather
'SL'      => $config['SL'],
// subject length in ACP - Ather
 
Open:
includes/functions_posting.php
Find:

Code: Select all

$subject = truncate_string($subject); 
Replace With:

Code: Select all

// subject length in ACP - Ather
$subject = truncate_string($subject, $config['SL']);
// subject length in ACP - Ather
 
Open
styles/YOURTEMPLATE/template/posting_editor.html
Find: (for prosilve)

Code: Select all

<dl style="clear: left;">
        <dt><label for="subject">{L_SUBJECT}:</label></dt>
        <dd><input type="text" name="subject" id="subject" size="45" maxlength="<!-- IF S_NEW_MESSAGE -->60<!-- ELSE -->64<!-- ENDIF -->" tabindex="2" value="{SUBJECT}{DRAFT_SUBJECT}" class="inputbox autowidth" /></dd>
    </dl> 
Replace With (if you want the textbox size to be the same of the value in ACP, change the size="45" to size="{SL}"

Code: Select all

    <dl style="clear: left;">
        <dt><label for="subject">{L_SUBJECT}:</label></dt>
        <dd><input type="text" name="subject" id="subject" size="45" maxlength="<!-- IF S_NEW_MESSAGE -->60<!-- ELSE -->{SL}<!-- ENDIF -->" tabindex="2" value="{SUBJECT}{DRAFT_SUBJECT}" class="inputbox autowidth" /></dd>
    </dl> 
To Adjust the settings, goto ACP-Board Configuration-Board Settings, you'll see a text box at the end, near the submit button, enter your value there and you'r all done :)

Screenshot:
Image
CPL Syed Ather Akbar
Regional Command Southwest
Camp Leatherneck, Afghanistan

My Mods/Snippets

User avatar
RiTz21
Registered User
Posts: 205
Joined: Tue May 31, 2005 5:20 pm

Re: Set max subject length in admin screens

Post by RiTz21 » Wed Dec 08, 2010 2:15 pm

Ather wrote:Ok, Here are the instructions required for you to edit it from the ACP, but you still have to do some file editing 1 last time :mrgreen:
A) Does this works in the latest release? (3.0.8)
B) When the next update is installed using the automatic updater, will these changes going to be lost?

Thanks!!
RiTz21
Image

Ather
Registered User
Posts: 1032
Joined: Fri May 08, 2009 9:42 am
Location: Kingdom of Bahrain
Name: Ather Akber

Re: Set max subject length in admin screens

Post by Ather » Wed Dec 08, 2010 3:47 pm

1.) Yes i tested on latest version of phpBB, it works
2.) Shouldnt be a problem, the updater merges the edits
CPL Syed Ather Akbar
Regional Command Southwest
Camp Leatherneck, Afghanistan

My Mods/Snippets

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51312
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Set max subject length in admin screens

Post by Brf » Wed Dec 08, 2010 3:54 pm

Have you tried it with UTF-8 multibyte characters, or simply with characters that get escaped? Those will make the stored-length of the string longer than the input length.

User avatar
onelazyguy
Registered User
Posts: 63
Joined: Sat Oct 02, 2010 2:55 am

Re: Set max subject length in admin screens

Post by onelazyguy » Fri Dec 10, 2010 7:26 am

Ather,

can you make this for subsilver2 template also?

thank you

you are great

User avatar
Jessica
Former Team Member
Posts: 4341
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: Set max subject length in admin screens

Post by Jessica » Fri Jul 08, 2011 12:30 am

doesn't work; I'm trying to type in "ABC News taps Elizabeth Smart as 'missing person' contributor" and I tried increasing the subject length - changed to 120, still can't type in the final letter "r"

did every file edit
Please do not PM me for support unless it is absolutely necessary
Pro-choice, Atheist, Pro-LGBT rights

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

Ather
Registered User
Posts: 1032
Joined: Fri May 08, 2009 9:42 am
Location: Kingdom of Bahrain
Name: Ather Akber

Re: Set max subject length in admin screens

Post by Ather » Fri Jul 08, 2011 5:18 am

ok, this should fix it :

open :
styles/YOURTEMPLATE/template/posting_editor.html

Find :

Code: Select all

    <dl style="clear: left;">
            <dt><label for="subject">{L_SUBJECT}:</label></dt>
            <dd><input type="text" name="subject" id="subject" size="45" maxlength="<!-- IF S_NEW_MESSAGE -->60<!-- ELSE -->64<!-- ENDIF -->" tabindex="2" value="{SUBJECT}{DRAFT_SUBJECT}" class="inputbox autowidth" /></dd>
        </dl> 
 
Repalce With :

Code: Select all

        <dl style="clear: left;">
            <dt><label for="subject">{L_SUBJECT}:</label></dt>
            <dd><input type="text" name="subject" id="subject" size="45" maxlength="<!-- IF S_NEW_MESSAGE -->{SL}<!-- ELSE -->{SL}<!-- ENDIF -->" tabindex="2" value="{SUBJECT}{DRAFT_SUBJECT}" class="inputbox autowidth" /></dd>
        </dl> 
 
If you have previously applied the edit, find and replace <!-- IF S_NEW_MESSAGE -->60 to <!-- IF S_NEW_MESSAGE -->{SL}

Screen :
Image
CPL Syed Ather Akbar
Regional Command Southwest
Camp Leatherneck, Afghanistan

My Mods/Snippets

Ather
Registered User
Posts: 1032
Joined: Fri May 08, 2009 9:42 am
Location: Kingdom of Bahrain
Name: Ather Akber

Re: Set max subject length in admin screens

Post by Ather » Fri Jul 08, 2011 5:33 am

Brf wrote:Have you tried it with UTF-8 multibyte characters, or simply with characters that get escaped? Those will make the stored-length of the string longer than the input length.
seems to work :
Image
CPL Syed Ather Akbar
Regional Command Southwest
Camp Leatherneck, Afghanistan

My Mods/Snippets

User avatar
Jessica
Former Team Member
Posts: 4341
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: Set max subject length in admin screens

Post by Jessica » Fri Jul 08, 2011 2:54 pm

it works now. thanks
Please do not PM me for support unless it is absolutely necessary
Pro-choice, Atheist, Pro-LGBT rights

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

Jabhi
Registered User
Posts: 572
Joined: Mon Feb 27, 2012 6:12 am

Re: Set max subject length in admin screens

Post by Jabhi » Sun Jun 10, 2012 3:46 am

Thanks, will try...
Go phpBB go... Respected : Developers, Supporters.

Locked

Return to “[3.0.x] MOD Requests”

Who is online

Users browsing this forum: Bettyrig and 16 guests