Fork me on GitHub

Rapport de message :*
 

Re: Augmenter la taille de la signature

Titre du sujet : Re: Augmenter la taille de la signature
par Cesagonchu sur 07/05/2015 12:22:40

En attendant que le problème de droits d'accès vers la Faq soit réglé, je colle le texte de la page de la Faq donné par Christian (c'est en anglais) :

Yes, by changing the field type in your XOOPS database and (if needed) tweaking a couple .php files you can have a larger signature or field contents.

Basics

XOOPS stores content and all sorts of information in a MySQL database. As database fields have size limits and sometimes the default field size isn’t the best choice for a given site, here are the basics of changing field sizes.

The main change to make is the field’s (column’s) type. You must have access to your XOOPS database (usually using phpMyAdmin) and be able to edit column types. Please refer to the MySQL Manual for a complete explanation on string types and type storage requirements.

Here’s a summary of storage limits per type of field:
CHAR, VARCHAR = 255 bytes
TINYTEXT = 256 bytes
TEXT = 65538 bytes (64KB)
MEDIUMTEXT = 16777219 bytes (16MB)
LONGTEXT = 4294967300 bytes (4GB)



Signatures

Sometimes, like with the signature field, simply changing the MySQL column type will be enough. Since 64kb is too large for a signature and there’s no intermediate type size, you can use the PHP substr() function in edituser.php:

Change:
$edituser->setVar(’user_sig’, $user_sig);

To:
$edituser->setVar(’user_sig’, substr($user_sig, 0, 1000));

This will impose a 1000 characters size limit to signatures.


Hacking .php files

Just as you can overcome the lack of granularity in MySQL size limits changing the way XOOPS inputs (or retrieves) data in the table, in some instances you’ll find field size limits hardcoded in .php files. To change this kind of field size, you’ll have to do as suggested above and then find the PHP files that deal with the field you want to change and edit them accordingly. As with all hacks, this will make future upgrades harder, so ponder carefully whether you really have to change .php files or not.

As an example of hacking hardcoded size limits, here’s what is necessary to edit to have larger RSS url fields in XOOPS Headlines module:

First thing to do is change the field type in MySQL: it’s set as VARCHAR(255) (255 characters) and you should set it to TEXT, which allows 65535 chars (unfortunatelly, there’s no intermediate value).

Then you have to change two module’s files:

Open /modules/xoopsheadline/admin/index.php and find and replace
form->addElement(new XoopsFormText?(_AM_URLEDFXML, ’headline_rssurl’, 50, 255, ’http:’), true);

(which appears, and has to be replaced, twice) with
$form->addElement(new XoopsFormText?(_AM_URLEDFXML, ’headline_rssurl’, 50, XYZ, ’http:’), true);
, ";XYZ"; being the new size in bytes for your RSS url field.

In /modules/xoopsheadline/class/headline.php, find
$this->initVar(’headline_rssurl’, XOBJ_DTYPE_TXTBOX, null, true, 255);

and replace ";255"; with the same value used before. This might be handy if you want to display customized Amazon RSS feeds.


Client-side textarea limits

If you need to post more than 65535 characters in a textarea you’ll have to edit a client-side limit implemented in /include/xoops.js (and perhaps /include/xoopsjs.php): find the line var maxchars = 65535; and change that value to fit your needs.
Propulsé avec XOOPS | Graphisme adapté par Tatane, Grosdunord, Montuy337513

58 Personne(s) en ligne (42 Personne(s) connectée(s) sur Forum) | Utilisateur(s): 0 | Invité(s): 58 | Plus ...