News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Allowing more HTML in posts and custom CSS

Started by Melonking, November 23, 2021, 01:19:14 PM

Previous topic - Next topic

Melonking

Hi, Id like to allow most HTML tags in posts (excluding head, link etc) and I would also like to allow users to add CSS that can modify the entire page around their topic.

For example Id like people to be able to change the font, background color of the page on a per topic level to fit the theme of their topic or just to let them screw things up if they want.

Essentially Id like people to have the same customizability on a per topic level as users do on their profiles on SpaceHey.

So I suppose there are 2 parts to this question.
  • How can I allow more HTML tags in posts other then the regular basic html tags?
  • How can I add a custom CSS box to the new topic page that will append the users CSS in a style tag?

Im aware there is an old mod called More HTML, I tried looking at its source to get an idea of how it worked but its using some sort of .mod format that cant be opened. Modifying the forum code is not an issue, I'm familiar with PHP and SQL, however Id value any pointers or a guide as to how to approach it, the forum source is a big unknown block of code to me.

Additionally I'm running on 2.0.18 version of the forum.

Diego Andrés


SMF Tricks - Free & Premium Responsive Themes for SMF.

Kindred

In short... BAD idea. There is a very good reason why we have restrictions on even the minimal styling html we do allow

All the rest needs to go through bbcode
Сл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."

Melonking

Quote from: Kindred on November 23, 2021, 01:24:58 PMIn short... BAD idea. There is a very good reason why we have restrictions on even the minimal styling html we do allow

All the rest needs to go through bbcode

The WORST thing I can think of is that free CSS styling could allow someone to make fake buttons that made you logout when you clicked on them or something. The idea though is that when you go onto a topic, you know its an at your own risk situation. I think in 99% of cases anyone styling the page would probably just make it their favorite color and call it a day.

shadav

for security reasons I don't think that what you are wanting to do is possible, as it would leave your forum open to hacking

that said there are things that you can do

see here where with some help from sir osis and ant I was able to get my header image to changer based on the board id
https://www.simplemachines.org/community/index.php?topic=573906.0

also if you go to your admin under forum and under boards and click modify for the boards you want to change you can set each board to use a specific theme instead of the default (which uses whatever theme is being used at the moment)
Board Theme:
This allows you to change the look of your forum inside only this board.

and well there are quite a few mods that you can install to help change the look and layout of the post itself, just not the actual page itself

Melonking

Quote from: Diego Andrés on November 23, 2021, 01:23:56 PMThis might be useful for you https://custom.simplemachines.org/index.php?mod=2505

Also thanks this is a cool mod, I did have a peek at it, If I cant get more html tags going this is defo the next best option!

Quote from: shadav on November 23, 2021, 01:32:37 PMfor security reasons I don't think that what you are wanting to do is possible, as it would leave your forum open to hacking

that said there are things that you can do

see here where with some help from sir osis and ant I was able to get my header image to changer based on the board id
https://www.simplemachines.org/community/index.php?topic=573906.0

also if you go to your admin under forum and under boards and click modify for the boards you want to change you can set each board to use a specific theme instead of the default (which uses whatever theme is being used at the moment)
Board Theme:
This allows you to change the look of your forum inside only this board.

and well there are quite a few mods that you can install to help change the look and layout of the post itself, just not the actual page itself

This is helpful! Its not exactly what I'm after but its a good case study about approaching a mod, I will study it!

For the CSS aspect it could be as simple as adding an extra text box to the topic creation page, then saving its contents to the database and loading it back when the topic is loaded (as a style tag).

As for the HTML tags, I suppose Im hoping there is just some text file somewhere that defines what HTML tags are allowed as part of the basic HTML support... BUT I'm getting the feeling its more complex than that?

EDIT: Also I think really I'm more interested in letting people modify the existing theme rather than having them pick predefined options, its about opening up peoples possible interactions rather than regulating everything.

Sesquipedalian

Quote from: Melonking on November 23, 2021, 01:31:22 PMThe WORST thing I can think of is that ...

Hackers have much more imagination than you do about these things.

UNDER NO CIRCUMSTANCES should you allow users to enter arbitrary HTML in their posts.

You ignore this advice at your peril.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Advertisement: