Adding Dynamic Routes in a Plugin

Hi Everyone,

to start of, I am pretty new at Ember and Discourse so excuse anything I ask that should be self explanatory… :slight_smile:

I am creating a plugin for a client and need to define some dynamic routes. I have done this in plane ember within 15 minutes, but can’t seem to get this to work in discourse.

Basically I need a routing structure like this:

Basically I have posts and need to define a show view per post.

Have these routes setup in plain Ember:

this.route('posts');
this.route('posts.show', { path: 'posts/:post_id' }

I have a controller setup that just returns some json, so the actual post_id wouldn’t matter.

Basically I understand that once you have a dynamic route, you should define a specific route that returns a model, which you can then use in the template.
Currently it is not working and returns a undefined property ‘post’ for undefined. So I’m guessing I need to do something more in discourse to get this to work.

Can someone point me in the right direction and/or point me to some documentation where I can get this information?

Thanks!

Tjaco

Did you checked this Beginner's Guide to Creating Discourse Plugins Part 5: Admin Interfaces?

1 Like

Yes I got that working just fine, but that is not using any dynamic route functionality.

I think the main this is that it tries to find the object in the discourse store. That is the discourse version of ember data(right?) and then it fails. So is there something I need to do to add it to the store? Or possibly ignore it going to the store?