Table style override 1.0.0

XF 2.3 Table style override 1.0.0

Add-on xenforo 2

Ressources et modules complémentaires pour XenForo 2

Styles xenforo 2

Styles / Thèmes et apparence pour xenforo 2

Templates xenforo 2

Codes pour modifier les templates sur xenforo 2

Section Premium

Add-on et Styles pour membre Premium
  • ⚠️ Section Premium. Réserver aux Membres Premium ⚠️
Table style override 1.0.0

XF 2.3 Table style override 1.0.0

Catégorie Catégorie Add-Ons
Titre du sujet Titre du sujet Table style override 1.0.0
Auteur de la discussion Auteur de la discussion laurent68
Date de début Date de début
Réponses Réponses 0
Affichages Affichages 4
Réaction Réaction 0
Dernier message par Dernier message par laurent68

laurent68

Fondateur

Staff
fondateur
Réputation: 100%
Discussions
4 944
Messages
12 883
Solutions
85
J'aime
8 033
Points
198
After upgrading from XF 1.5, I had more than 1100 threads that used a custom bbcode to make tables. They looked like this:

Code:
[TABLE="width:800px,text-align:center"]
[TR="bgcolor=grey"]
[TD="text-align:left,font-weight:bold"]
...
... etc ... etc

Well, the built in TABLE bbcode did not handle that at all, and the raw text (no formatting at all) just showed in these threads. None of the table bbcodes i found could be easily switched to without manually updating a thousand+ posts, or writing a complicated program to convert all the bbcodes to a different format.

So, I wrote the attached code. Now, because of how XF 2.3 treats bbcodes, the [TABLE="xxx"] and [TD="xxx"] just wouldnt work. So I had to do a couple of DB queries to change these.

SQL:
UPDATE xf_post
SET message = REPLACE(message, '[TABLE=', '[TABLE STYLE=')
WHERE message LIKE "%[TABLE=%";

UPDATE xf_post
SET message = REPLACE(message, '[TD=', '[TD STYLE=')
WHERE message LIKE "%[TD=%";

Then i wrote an addon to handle the above. Funny enough, I had to leave the [TR="xxx"] code as it was, as switching it to the same format as the above didnt help.

So, this is VERY niche, and probably not very helpful to anyone. BUT, it does show how to intercept and override the built-in
code, and I hope that it has good educational value.

The screenshots show some sample bbcode, then a rendered table (which only renders at all because of the SQL changes) without the plugin enabled, and finally the same post with the plugin enabled.

Télécharger V1.0.0 :
 

Pièces jointes

  • plug1.webp
    plug1.webp
    114.8 KB · Affichages: 2
  • plug2.webp
    plug2.webp
    48.9 KB · Affichages: 0
  • plug3.webp
    plug3.webp
    52.5 KB · Affichages: 0
Contenu similaire Les plus vues Voir plus
Retour
Haut Bas