totaljs / cms

Node.js Content Management System
http://www.totaljs.com/cms/
MIT License
223 stars 92 forks source link

how to use totaljs's blogengin app in sub domain of cms #22

Closed rzrezaie closed 5 years ago

rzrezaie commented 5 years ago

hi dear total.js team i use your both cms and eshop app in my local machine. everything work but in both app i can not list posts by category. here is what i do : 1- in setting page i defined some sample category eg news, tutorial ,... after saving i go to step 2- create some post in each category. but blog page only show all posts and by click on each post it show post detail. i want to do list posts buy category too, just like products on eshop app. I tried so whit no success. then decided to use totaljs blogngine as sub domain under cms ( eg: http://BlogEngineAapp.CmsApp.local) and read your documentation and sampls but again whit no sucsess. i can not undrestand how it work. is this bug? can any one help me? is there any book for total.is or related tutorial?

petersirka commented 5 years ago

Hi @teseh, just extend default.js controller by adding:

exports.install = function() {
    // ....
    ROUTE('/posts/news/',   view_posts_news, ['*Post']);
    // ....
};

function view_posts_news() {
    var self = this;
    var options = {};

    options.page = self.query.page;
    options.published = true;
    options.limit = 10;

    // IMPORTANT:
    options.category = 'news';

    self.$query(options, self.callback('posts'));
}