cliftonc / calipso

Calipso is a simple NodeJS content management system based on Express, Connect & Mongoose.
calip.so
1.71k stars 307 forks source link

Add better comments to template module #45

Open adrinux opened 13 years ago

adrinux commented 13 years ago

So. If the example 'template' module has:

/**
 * Every page block function
 */
function allPages(req, res, template, block, next) {

  var myVariable = "Hello World on every page!";
  var item = {
    id: "NA",
    type: 'content',
    meta: {
      variable: myVariable
    }
  };

  calipso.theme.renderItem(req, res, template, block, {
    item: item
  },next);

};

Why doesn't a block with "Hello World on every page!" appear on every page? I started work on an admin toolbar module, https://github.com/adrinux/calipso/tree/module-toolbar but can't fathom why a block isn't appearing, despite looking at core/community modules.

cliftonc commented 13 years ago

The module needs to be turned on, and the block needs to be rendered in a template within the theme. If you look in the init function, you will see that by default that function renders to a block called 'right', so this needs to be included in the right.js / right.html in the theme (the name is just a key, you have to include it for it to appear).

You will see that for most things, the block is something like content.blah - and the theme typically uses a regex to render anything /content.*/ to the body element of a page. The template module isn't actually a great example any more, specifically with cleanslate as it doesn't include it by default ... needs to be fixed!

HTH

Clifton

cliftonc commented 13 years ago

Also - note on the other issue, is that it definitely shouldn't be called right! :)

dennishall commented 13 years ago

On the other hand, including too many things in cleanslate would turn it into a misnomer.

I think that the 'template' module just needs beefier comments. A good place to start might be to paste your comment in this thread at the top of the template module.

dennishall commented 13 years ago

@adrinux / cliftonc - comment & close [this thread]?

adrinux commented 13 years ago

A more descriptive title - haven't had time to get back to this issue yet.

cliftonc commented 13 years ago

Will target a full breadth example / template module for the 0.3.0 release.