Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 23 01:47
    trentmillar closed #5011
  • Nov 23 01:45
    trentmillar opened #5011
  • Nov 20 15:13
    Enzaik commented #3994
  • Nov 20 15:13
    Enzaik commented #3994
  • Sep 13 13:31
    brooksbecton commented #59
  • Aug 30 10:36
    VoronV48 commented #1069
  • Aug 30 10:35
    VoronV48 commented #1069
  • Aug 30 10:35
    VoronV48 commented #1069
  • Aug 24 03:37
    VoronV48 commented #5001
  • Aug 17 11:00
    emollett closed #5010
  • Aug 17 11:00
    emollett opened #5010
  • Aug 17 10:31
    emollett closed #5009
  • Aug 17 10:31
    emollett opened #5009
  • Jul 27 18:26
    taswarabbassss commented #3994
  • Jul 20 18:58
    jamiebuilds closed #4136
  • Jun 17 05:20
    jossmac unassigned #3262
  • Jun 14 20:06
    jupazave closed #4555
  • Mar 18 16:42
    apfel-das commented #3994
  • Mar 06 07:07
    sounishnath003 commented #3994
  • Feb 15 03:45

    dcousens on point-readme-to-ks6

    (compare)

tsuNammi
@tsuNammi
tried
view.render('post', {title: locals.data.post.title});
didn't work dude
TypeError: Cannot read property 'title' of undefined
tsuNammi
@tsuNammi
trying to do:
// Load the current post
view.on('init', function (next) {

    var q = keystone.list('Post').model.findOne({
        state: 'published',
        slug: locals.filters.post,
    });

    q.exec(function (err, result) {
        locals.data.post= result;
        console.log(result);
        title: locals.data.post.title;
        next(err);
    });

});
then
view.render('post');
but does not work
Max Ma
@max8hine_twitter
Hi, @tsuNammi, locals object is the object will pass down to your view. so if you want to load the title from view. you need make sure the key of 'title' nested the locals object directly.
view.on('init', function (next) {

    var q = keystone.list('Post').model.findOne({
        state: 'published',
        slug: locals.filters.post,
    });

    q.exec(function (err, result) {
        locals.data.post= result;
        /* Try this */
        locals.title: locals.data.post.title
        console.log("Locals: ", locals)
        console.log("Locals > Title: ", locals.title)
        next(err);
    });

});
Max Ma
@max8hine_twitter
Yes, keystoneJS need some helps for their documents. it is missing some of explanation for the APIs which is very important in build. Check out this site, http://keystonejs.netlify.com/guides, it did helped me somehow,
the above link explained why use view.on('init') over view.on('get') in indirect way. 🤔
tsuNammi
@tsuNammi
thanks man, but I guess I've already handled it with if/else statements in the headerpartial file. it's not nice and clean, but I figured if ppl went to a /post/id-that-does-not-exist, the only problem wouldn't just be the title
there's a lot of stuff in the post-template that would need to access a data.post which does not exist, and I can't handle them cleanly at the same time
doesn't matter anyways
I just send them to a 404/500 error default page instead handling all the errorenous database calls for an object that doesn't exist with if/else before actually making a default template with 'post not found'
unless anyone else has a better idea when ppl try to access a post/'slug' that does not exist
Arran Short
@sordfish
Hi All, is there a way to detect if data has come from an update in a model? basically I want to add a mongoose post hook that only triggers from admin ui saves and not updates.
Arran Short
@sordfish
woo @JedWatson is back
Max Ma
@max8hine_twitter
@sordfish have you tried the getUpdateHandler API from keystone? that API could help me to modify the data before update the model.
tsuNammi
@tsuNammi
so I tried deploying today
ran into a reaaaally weird problem
I have <strong> tags all over when I "inspect" using Chrome Inspector
they don't appear when I "view page source"
it's messing up my front end
I have no idea where to begin
it has something to do with the text that I've fetched from MongoDB
maaaybe because I have some a tags and strong tags entered into the content in the MongoDB
it appears normal when I access mongo shell and look at the objects
or it started when I started filling in stuff with a/strong tags in I think
but I have the same code running on cloud9
and no problems there
tried downgrading node versions to match cloud9's
but no success
tsuNammi
@tsuNammi
found out what it caused it
it was a if/else statement within a forEach.function() that would either .substring () a data entry from MongoDB or not based on str.length
removed the if/else statement and it worked instantly
weird though
tsuNammi
@tsuNammi
well update;
it wasn't just the if/else
it was the substring method itself
so I had to remove it
the everything was fine
substring() on a data.post.brief inside a forEach(function()
maybe something async stuff that does this ?
anyways, OK for now, kinda sucks if it was for a real customer
Ghost
@ghost~56835aa516b6c7089cc090e9
hey there - i last used keystone around 2 years ago, so i forgot a lot of things about it
i vaguely remember needing to use a command-line utility to create models, but can't find any mention of it in the documentation