-
-
Save dethe/1252291 to your computer and use it in GitHub Desktop.
/** | |
* Additional content section / block functions for body. | |
*/ | |
var rootpath = process.cwd() + '/', | |
path = require('path'), | |
calipso = require(path.join(rootpath, 'lib/calipso')); | |
exports = module.exports = function(req, options, callback) { | |
/** | |
* Get additional content for blocks in the template | |
*/ | |
calipso.lib.step( | |
function getContentList() { | |
var alias = options.getPageId.split('.')[0]; | |
options.getContentList({alias:alias}, {req:req}, this.parallel()); | |
}, | |
function done(err, contentlist) { | |
var content = contentlist.contents[0].toObject(); | |
callback(err,{ | |
project:content.content, | |
summary:content.summary, | |
equipment:content.equipment, | |
awards:content.awards | |
}); | |
} | |
); | |
}; |
Yes - fork and work from that, you'll get used to github, once you submit a few pull requests and see how much easier it makes review etc. you'll be hooked.
I've just committed some changes to devel that sort of solve your problem in the short term, but not fix the longer term over-ride of content templates by content type (needs work!).
-
New helper: getParams() -> returns all the module params gathered during routing stage.
-
Changes: getContent changes ->
options.getContent(req, "welcome-text", this.parallel()); => Will return the content property of matching content as before.
options.getContent(req, {alias:"welcome-text",property:"content"}, this.parallel()); => Will do same as above.
options.getContent(req, {alias:"welcome-text",property:"title"}, this.parallel()); => Will return the title property of matching content.
options.getContent(req, {alias:"welcome-text"}, this.parallel()); => Will return the content object itself (as you don't specify a property).
Let me know if this helps.
Clifton
Hi Clifton, maybe I'm not following this right. I've been testing the Calipso code base for two days now. First with the NPM package. Now with the source code using the devel branch. I forked it and cloned my fork making sure to switch to the devel branch and then running the node app.js
from the source directory. Now I'm trying to figure out how to use these custom fields from the content type custom fields tab. I looked at this thread
cliftonc/calipso#117
Maybe its all explained but I'm still not following. I took the gistfile1.txt and used it in the
themes/core/cleanslate/templates/home/body.js
restarted the server, created a content type home, then created content using type home and got this console error and server crash.
/Users/jgs/Projects/calipso/node_modules/mongoose/lib/utils.js:413
throw err;
^
TypeError: Cannot call method 'toObject' of undefined
at Function.done (/Users/jgs/Projects/calipso/themes/core/cleanslate/templates/home/body.js:20:43)
at next (/Users/jgs/Projects/calipso/node_modules/step/lib/step.js:51:23)
at /Users/jgs/Projects/calipso/node_modules/step/lib/step.js:83:14
at Promise.<anonymous> (/Users/jgs/Projects/calipso/modules/core/content/content.js:938:9)
at Promise.<anonymous> (/Users/jgs/Projects/calipso/node_modules/mongoose/lib/promise.js:120:8)
at Promise.EventEmitter.emit (events.js:95:17)
at Promise.emit (/Users/jgs/Projects/calipso/node_modules/mongoose/lib/promise.js:59:38)
at Promise.complete (/Users/jgs/Projects/calipso/node_modules/mongoose/lib/promise.js:70:20)
at cb (/Users/jgs/Projects/calipso/node_modules/mongoose/lib/query.js:918:32)
at /Users/jgs/Projects/calipso/node_modules/mongoose/lib/utils.js:408:16
What I'm trying to figure out is if I can create a template with custom fields.
p.s. if you switch to github, you can run it straight from a clone, but you need to:
and if you want to use the calipso cmd line, you need to use it like this:
You need to locally reference it, and the -s is to indicate that it is running from the source rather than a site install.
For module and theme development, I typically create a custom folder inside modules & themes, and then just git clone the other modules/themes from their repositories into there - this means you can work on the modules and themes separately but still run it all as one site - hth.
The devel branch has all the non-core modules removed.
Clifton