The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
4 posters

    How to replace a forum tag to an html tag?

    congdantoancau
    congdantoancau
    Forumember


    Male Posts : 77
    Reputation : 4
    Language : Vietnamese
    Location : Vietnam

    In progress How to replace a forum tag to an html tag?

    Post by congdantoancau July 31st 2022, 11:16 pm

    hello
    I want to replace [size=48]text[/size] to <h1>text</h1> and the same as [size=32]text[/size] to <h2>text</h2> in the .post-entry.
    How can I do that? Please help me!
    Thanks in advanced!

    p/s: I adready known how to insert a script to Javascript codes management module but don't know how to code a script to replace them
    Niko
    Niko
    Helper
    Helper


    Male Posts : 3283
    Reputation : 254
    Language : English, Italian, French
    Location : Italy

    In progress Re: How to replace a forum tag to an html tag?

    Post by Niko August 7th 2022, 5:36 pm

    Dear @congdantoancau

    do you want this to be effective on topics view, right? It's something with effect after the topic has been published, is it?

    :rose:
    congdantoancau
    congdantoancau
    Forumember


    Male Posts : 77
    Reputation : 4
    Language : Vietnamese
    Location : Vietnam

    In progress Re: How to replace a forum tag to an html tag?

    Post by congdantoancau August 7th 2022, 8:06 pm

    Niko wrote:Dear @congdantoancau

    do you want this to be effective on topics view, right? It's something with effect after the topic has been published, is it?

    :rose:

    Yes, I want to affect it when the topics is loaded.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3523
    Language : English
    Location : United States

    In progress Re: How to replace a forum tag to an html tag?

    Post by SLGray August 7th 2022, 8:42 pm

    Are you talking about this?
    How to replace a forum tag to an html tag? H210



    How to replace a forum tag to an html tag? Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    Niko
    Niko
    Helper
    Helper


    Male Posts : 3283
    Reputation : 254
    Language : English, Italian, French
    Location : Italy

    In progress Re: How to replace a forum tag to an html tag?

    Post by Niko August 8th 2022, 8:01 am

    [quote="congdantoancau"]
    Niko wrote:Yes, I want to affect it when the topics is loaded.

    and sorry @congdantoancau, forgot to ask, is you forum version Invision, right ?

    edit: if so, give a try with this javascript code:

    Code:
    $(function() {   
        $('.post-entry div').each(
        function(){
            var content = $(this).html().replace(/\[size=32\]/g,'<h2>').replace(/\[size=48\]/g,'<h1>').replace(/\[\/size\]/g,'</h2>');
            $(this).html(content);
    });
    });

    SarkZKalie, TonnyKamper and congdantoancau like this post

    congdantoancau
    congdantoancau
    Forumember


    Male Posts : 77
    Reputation : 4
    Language : Vietnamese
    Location : Vietnam

    In progress Re: How to replace a forum tag to an html tag?

    Post by congdantoancau August 10th 2022, 9:00 pm

    [quote="Niko"]
    congdantoancau wrote:
    Niko wrote:Yes, I want to affect it when the topics is loaded.

    and sorry @congdantoancau, forgot to ask, is you forum version Invision, right ?

    edit: if so, give a try with this javascript code:

    Code:
    $(function() {   
        $('.post-entry div').each(
        function(){
            var content = $(this).html().replace(/\[size=32\]/g,'<h2>').replace(/\[size=48\]/g,'<h1>').replace(/\[\/size\]/g,'</h2>');
            $(this).html(content);
    });
    });

    Thanks you very much! It works. I didn't thought that was so simple before. Think it might need to use REGEX or something

    Niko likes this post

    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15391
    Reputation : 1709
    Language : English,Greek
    Location : Greece

    In progress Re: How to replace a forum tag to an html tag?

    Post by skouliki August 11th 2022, 3:48 pm

    When your request is complete, please mark it as Solved.


      Current date/time is November 11th 2024, 2:48 pm