NodOnce : Think · Make · Launch

an ee.startup

what is genes.zone?

contact telegram twitter
genes:one
API

Mods, Usage and Custom Mods

What are mods? Do you really need them?

There are default couple of mods packed with the Genes. But, you don't have to use them.
With Genes, you're not forced to bulk up your applications.
You can keep it as thin as you want.

For a simple semi-static Clone with no admin, no login, just a simple multilingual landing page for a campaign of yours, you can easily use a Mod-less Genes.
The data may be kept in config.json, or any part of it that can be separated, or in the html parts that change depending on the language.
You can easily manage such website with no Mods whatsoever.

But, what is you want to use a newsletter module, and the admin interface so that you can edit the content whenever you want?
Than you have two options.
You can still not use Mods. (What's with you and the Mods?) And bake everything into your application functions.
Or, you can use, well, yes, Mods. Just saying...

Mods are like plugins that modifies the Genes to add some functionality that you may have to repeat, and/or use anywhere else.
You don't need to create a User Mod for every time you create a new Community Clone.
As long as you have it in your server's Genes folder, you can just add a key to your config.json, and it is activated.


  <?php
    // THIS IS A VERY SIMPLE NOTE-TAKING MOD FOR GENES
    // THIS PART MODIFIES THE CONFIG FILE WHEN YOU ACTIVATE IT
    g::set("void.notes", array(
        "views" => array(
            "NotesAdd" => array("urls" => array("en" => "notes=add")),
            "NotesEdit" => array("urls" => array("en" => "notes=edit")),
            "NotesDelete" => array("urls" => array("en" => "notes=delete")),
            "Notes" => array("urls" => array("en" => "notes=list")),
        ),
        "bits" => array(
            "notes" => array("en" => "Notes"),
        ),
        "tmpls" => array(),
    ));
  
    // THIS PART IS FOR THE FUNCTIONS TRIGGERED WHEN ANY VIEW ABOVE IS CALLED
    g::def("mods.notes", array(
      "Init" => function () {
          g::set("op.meta.url.mod", "Notes");
      },
      "Notes" => function () {
          g::run("mods.notes.Init");
          $args = g::get("op.meta.url.args");
          $post = g::get("post");
          ...
      }
      ...
    ));


          

You just need to add a "notes": {} subkey to "mods" in config.json and the rest is filled via the Mod automatically.


  "mods": {
    "notes": {
      "views": {
        "NotesAdd": {
          "urls": {
            "en": "notes=add"
          }
        },
        "NotesEdit": {
          "urls": {
            "en": "notes=edit"
          }
        },
        "NotesDelete": {
          "urls": {
            "en": "notes=delete"
          }
        },
        "Notes": {
          "urls": {
            "en": "notes=list"
          }
        }
      },
      "bits": {
        "notes": {
          "en": "Notes"
        }
      }
    }
  }
  ...


          

You'll get the hang of it...

×

Contact NodOnce : Say Something!