Setting Up A Category System In My Application - meteor

So just today I've started using Meteor(myself being strictly a front-end designer) to try and turn one of my latest creations into a well-built dynamic web application.
The majority of the project is based around a forum structure so I am trying to build a hierarchy between Categories, Forums, and Threads. My current approach is to have separate collections, one for the forums/categories, and another for the threads, and then another for the posts.
My current dilemma is that I'm having an issue(fundamentally) as to how I will call all of the forums under a category. My current structure is setup where each forum has a "parent" set to the ID of the category they go under but I'm just not sure how I am going to go about getting them to display properly organized.
My current approach is to have a {{>Categories}} template, and then inside that template is:
<template name="categories">
{{#each cname}}
<div class="category">
<div class="title">{{name}}</div>
{{> forums}}
</div>
{{/each}}
</template>
And the logic I used to display all of the categories is(type: 0 defines it as a category):
Template.categories.helpers({
cname: function() {
return Forums.find({type: 0})
}
});
Now the {{>forums}} helper I'm just completely stuck on. Here is what the template looks like:
<template name="forums">
{{#each fname}}
<div class="forum">
<div class="ficon"><i class="{{ficon}}"></i></div>
<div class="fname">{{name}}<br><div class="fdesc">{{description}}</div></div>
<div class="fstats">{{threads}}<br><span class="sub">Threads</span></div>
<div class="fstats">{{posts}}<br><span class="sub">Posts</span></div>
</div>
{{/each}}
</template>
I can get it to show all of the forums, but I am still confused as to how I will make the specific forums show up only under the specific categories in the listing.
If anyone is willing to help that'd be awesome!

The easiest way would be to denormalize, and include the "category" field right in your post collection. If you don't want to do that, you need to use some kind of joins - a db query that incorporates data from two collections.
There are reactive and non-reactive joins, as well as several other considerations that depend largely on how you want your app to work, but there is an abundance of information here:
https://www.discovermeteor.com/blog/reactive-joins-in-meteor/
This question is probably a little on the broad side, but hopefully this will get you started :)
EDIT: On reading the question again, I saw that you wanted to create a hierarchy, and hence the extra collections. Mongo is really not great for relational data, and starting with three collections like this will definitely make things harder for you. FWIW, I highly recommend denormalizing to include the category and forum information in each post.

Related

where should you subscribe to publications

I'm learning so if this is a silly question feel free to let me know. My question relates to subscription and where you should subscribe. Let me be more specific with an example.
files
template.html
templatePieceOne.html
templatePieceTwo.html
In this example we have a template.html that will render using two separate template pieces. The template pieces might be used else where on the website. Is it better to subscribe at the top level template.html, template.js, or should the template pieces each have their own subscription.
If this doesn't make sense please let me know.
You definitely shouldn't subscribe in every template. Instead, you should decide which templates correspond to an independent part of the application, i.e. a view, modal or widget. Those templates should be responsible for subscribing to, managing and passing down their data.
This way you'll be able to see easily which part of the application is active at any given moment and what it subscribes to.
I recommend the following article on
presentation and container components.
Even if you're using Blaze instead of React the idea is still valid.

Varying menus by page meteor kitchen

I've been using Meteor Kitchen to develop the structure of my site - pages, logins etc., and on the whole it's been very productive. However I would like the some of the items in the menu to vary by page, rather than be consistent throughout the site. I can vary the menus by zone (Public, Private, Free), and by user type, but I haven't figured out how to vary them by page (route). How is that done?
I'm looking for information about how to use the code generation tool, rather than specific code advice.
Your menu system is most likely expressed as HTML inside a blaze template. The most basic approach is to wrap the elements in your menus with {{#if }} blocks driven by whatever conditions are necessary to show/hide items.
You can also define menus as separate templates and swap the whole thing in:
{{#if condition1}}
{{> menu1}}
{{else}}
{{> menu2}}
{{/if}}
According to the author, Petar Korponaić, the "main idea behind Meteor Kitchen is to build as much code as possible in the beginning." It looks like I've reached that point - the end of the beginning - so I now need to switch to hand-coding, which makes Michel Floyd's response, to use the Spacebars {{#if }} blocks in the template, the appropriate response.

Should I use custom taxonomy or custom post type?

I've recently taken on a project from a client of mine, after a lot of persuasion I've managed to finally get the website under some kind of CMS. I'm pretty new to Wordpress I've come from an ExpressionEngine background and fancied trying something new for a change, so excuse the lack of knowledge (I'm trying my best! :D).
Now The issue I'm currently facing is that they have very specific directions regarding how they want their content displayed on their website and more importantly how they would like to manage it. They are a travel agent I'm currently putting together the resort directory that will display all of the resorts they offer.
In regards to the current structure of the directory it will be made up of 4 different sections. To give you a better understanding of how I want things to work take a look at this hierarchy below, (I've used turkey as an example, these would need to be dynamic):
/destinations/ This will be our destinations page that will list
all of the countries they currently
offer. I imagine this to be a static
page with some content about the
countries on offer with a list of the
countries below (These will be our
parent taxonomies).
/destinations/turkey/ This will be our parent taxonomy. This
page will also have to have the
ability to add some static content to
insert information about the country
and its locations. Below this will be
a second list, these will be the
different areas of turkey (These will
be children of the parent
taxonomies).
/destinations/turkey/belek/ This will be our child taxonomy, This
page will again need to have the
ability to add some static content.
It will also include our list of
resorts that my client offers within
this location (These will be our
entries/posts).
/destinations/turkey/belek/resort-name
This will be our post/entry page,
here we will have all of the
information on the select resort, the
specifics of this aren't an issue and
I've already got this sorted.
Now, I've done a lot of reading up on custom post types, custom taxonomies and their abilities and uses but I'm hit with a situation at the moment where I can't decide on which route I should take. I've been experimenting over the last few hours with the setup of one custom post type (for resorts) and one hierarchical taxonomy (for locations). Which works some what ok BUT due to the limitations of the taxonomy UI within the admin panel it doesn't allow me to add my static content/images etc. (I'd much prefer to use a WYSIWYG especially from a clients point of view).
So this makes me wonder if it would be worth making two custom post types and scrapping taxonomies all together, making one of the post types resorts and the other locations. With the locations post type I could set it up like the pages module (which would give me hierarchical controls to allow me to organise my locations how I had originally planned) but is this a wise move? I mean from what I've read you shouldn't really organise content this way but I've got a feeling that maybe just a clash of contextual semantics (I could be wrong!). Would there be any limitations for me setting things up this way should I wish to add search functionality in the future? Or anything else for that matter?
I thought I'd mention this before I FINALLY click the submit button (apologies for the great wall of text) but pages... I've read here that they are powerful little gems within Wordpress, how should I be taking advantage of these if I'm using custom taxonomies? How well do they work with listing categories are they what I need?
Right, that about wraps up everything I've got to ask for now - maybe I should have split this into a few posts but hey! I hope this gives you guys enough information about what I'm trying to achieve and please if I am going wrong feel free to point me in the right direction I'm really eager to learn more about Wordpress and it's capabilities.
Regards
Danny
While this is one approach, it sounds like what you really want to be using (rather than custom post-taxonomies) is simply the Page functionality of WP. Everything you're describing is simply the hierarchical structure of the navigation of your pages. Yes, you can use the custom taxonomies to accomplish this same thing, but since you're describing things that tend to be "one" thing (ie: a single resort) you probably don't need the taxonomies.
You might want to look at another option: PODS CMS http://podscms.com
This will give you a simple structure to add custom features to your posts relatively easily... Things like pricing, amenities, and other "organizable" details can be stored using PODS and then referenced across your site for better usability. It might be worth a look!

Drupal comments per fields

I have been looking all over for this, but so far without any luck. Is there a way to have comments per field instead of per node in drupal? If there are no modules available for this, do you think it would be hard to implement?
I thought I could make a "pseudo-content-type" with views that's nothing more than several content types displayed one on top of the other, so you could comment any of them. But then I don't know a way of making the user create all those content types at once.
The built-in comment module is not going to do comments per field on a node. I've been drupaling for almost three years and I don't know of any module that allows comments per field.
It is possible to do, but it would take a custom module and plenty of slick programming to get it to work. As far as difficulty I think an intermediate PHP developer with some knowledge of Drupal should be able to whip this out.
A kind of quick solution would be using panel module; form all your commentable content in nodes ad put them together all into a panel. This is kind a quick and static solution, possibly with views one can make it more custom.

How can I categorize the content types on the Drupal "Create content" page (/node/add)

How can I categorize/organize the content types on my "Create content" page? I'm running Drupal 6.x with CCK. I have a lot of custom content types, and my "Create content" page has become a bit unwieldy, as it lists them all alphabetically. I'd like to organize them by category, so users would see something like:
Create Content
Reports
Report Type A
Report Type B
Events
Event Type A
Event Type B
I don't want to mess with Core, but anything else (custom module, theming, existing module functionality) is fair game. I'm hoping I'm missing something easy, because this seems like an obvious requirement, but all I could find on the Drupal site were these unanswered questions:
Organize Create Content Page
(node/add)
Core: Split create
content page into categories?
You should be able to accomplish this in a custom module, without hacking core.
You'll want to implement hook_menu_alter() to take over the callback function for node/add.
Something like
function mymodule_menu_alter(&$items) {
$items['node/add']['page callback'] = 'mymodule_node_add_page';
}
should get you started. You would then create the function mymodule_node_add_page, and you could use the original callback function as a starting point.
You can also do this at the theme level by overriding theme_node_add_list().
There are some different ways to attack this problem. You can overwrite the old form page or just create a new one with a custom module. Doing that you can in your module do whatever your want.
Another possibility is to do the same thing using views instead. Doing that gives you access to a lot of powerfull features, as you can do anything the views module lets you do. You can create different ways of sorting the content types.
I've heard of many who have used views to make a page like this for the create content page. Which method you choose is up to you, depending on how exactly you want to do this and the data you have associated with your content types, one will be more easy than the other. But without knowing the exact details, I can't say which. I would advise you to start out with views, since you quickly should be able to find out, if you can use it to get what you want.
there's a module that does what you are looking for, Content type groups
I created a sandbox module some time ago which was supposed to do this:
https://drupal.org/sandbox/YaronTal/1260038
The only problem is that I wasn't able to create the admin backend with draggable interface at the time.
I know the issue is old, but just in case someone else has the same problem...

Resources