I want to start small and work within the confines of extend.php to develop additional functionality before creating a standalone extension.

I've read all the documentation i can find, but i learn best by simple, practical & relevant examples that act as a starting point i can analyze and incremental add onto, learning from any mishaps along the way.

So if it's not too much to ask, would anyone be able to post their complete extend.php to illustrate a simple, but useful example such as adding a <p> tag to the Sign up Modal (SignUpModal.prototype) or button etc.

I know there are extensions i can review, and i have, but I need to start really simple without any complications as I'm still familiarizing myself with Typescript.

Any other advice, resources, tips & tricks, please share! 😄

    johnhoward adding a <p> tag to the Sign up Modal (SignUpModal.prototype)

    To do that you would just register a js file and do the main part there. I recommend using ReFlars ectension generator for the basic structur of the Extension.

    So, to do what you want the extend.php would look like this:

    <?php

    namespace AUTHOR\EXTENSION;

    use Flarum\Extend;

    return [
    (new Extend\Frontend('forum'))'))
    ->js(__DIR__.'/js/dist/forum.js'),
    ];

    And the js file like this:

    import app from 'flarum/app';
    import { extend } from 'flarum/extend';
    import SignUpModal from'flarum/components/SignUpModal';

    app.initializers.add('author/extension', () => {
    extend(SignUpModal.prototype, 'fields', function (items) {
    items.add('p', <p>Your Text.</p>, -30);
    });
    });

      I just take any working extension as a guide and a learning tool and start doing minor changes from there. I kinda hate the js thingy but to create a proper flarum extension requires proper understanding (if not mastering) javascript as well.

      Kvothe Thanks for this!

      I just used the extension generator to set it up and it worked great! I got it registered and enabled, but i ran into an error i can't figure out. Without modifying the generated files, the console reported:

      SyntaxError: export declarations may only appear at top level of a module
      TypeError: flarum.core is undefined

      from forum-75ee5cce.js. Is this a common issues anyone has ran into that i don't know about? If not, i can post more info to help in the morning.

      Thanks

        johnhoward Not sure but you may have put the js at the wrong place. You need to put it into src>forum/index.js, when you set it up with Reflars generator.
        You also need to set up a Transpiler, if you haven't already done it. You can read about it here. Don't worry about the config files, they were already setup by the generator. You just need to get Node.js, npm and webpack and run the described commands.

          Kvothe Installed those packages and re-ran generator and got it all working. I managed to accomplish the majority of what i wanted to do after getting a good footing (thank you!).

          3 years later

          This application only for experts..This is the main problem with this application.. nobody can explain what exacly happening

            dhaneshsnair1988 please share the issues you are running into so that:

            a) we can provide targeted support
            b) improve Flarum for similar use cases in the future

            A "this sucks" remark doesn't help anyone 😉