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.
Related
What are the best practices for placing common data for many views (twig), eg. main menu, bottom menu, breadcrumbs, etc.
I know that I can do it using embedded controllers, but it is not very efficient.
Many commonly used things can be accessed by using the built in variabble app, ie {{ app.user }} returns the currently logged in user.
If you need something else you can write your own twig extensions.
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.
I'm new to Drupal. As I understand a Drupal(7 in my case) page normally would have layers of wrappers around a block, sections, regions etc ... What I'm trying to achieve is to render some arbitrary content directly into "body" with none of the wrapper overheads, while keeping everything in "head". I've researched hook_block_list_alter which allows you to exclude blocks before rendering - which doesn't offer the ability to customize (removing) sections. Then I came across hook_page_alter looks like a good way to go, although I haven't dug too deep yet, still trying to understand the structure of the $page object. I thought about other options such as using the context module to configure sections/zones when requested page url is in certain pattern.
What's "THE Drupal's way" of doing this?
I would suggest you to first try with Drupal's template system and then, if you can't achieve something try with hooks:
https://www.drupal.org/node/337173
So, as you mentioned drupal has layer templates wrapping one around another. Most outer one is html.tpl.php and if you want something to appear in page head put it there. Then, second inner one is page template, which can be different for any content (node) type. But you also have block templates, field templates...
To override templates for specific content type or field or something else Drupal has some special naming convention. So if you name you template some specific way (and clear the cache!) drupal will start use it in that specific case.
Check the documentation for more details.
I have few queries regarding CQ. Your reply will really make the difference to my understanding.
1) Why exactly do we need template when what all template do is to have a resourceType property attached to a content-page component. At the time of creating new page, shouldn't authors directly select that component ?
2) In other CMS like Vignette, content authors create the contents separately (not directly on the page) for ex. products details and then those contents are iterated / processed to display on the page. But in CQ, the scenario is other way round. Authors directly create the content on the page. Now if same content is needed on other page, how will that be re-used ?
3) For pages like product details, there is a fixed structure of the content like product image, description etc. Now if there is parsys component used (widely used in geometrixx demo site), there will be possibility to add the any of the allowed components in any order in parsys. Will not this create content chaos ? OR it will be author's responsibility to add it as needed by page structure ?
Regards,
Ronak
1) That is actually a good question, it would make more sense to somehow identify a component as page template. Though there is one reason for a template: The developer can already have some properties and even components within a parsys preset.
2) There is a Reference component in the foundation components which is for this exact use case. Within the dialog you can select any component from any other page. So you can create a dummy page outside of the navigation with frequently used text and reference them when needed.
3) That is always the problem between defined structure and author freedom. Each customer has to decide what is best for him. Though usually I end up having to give the author too much freedom for my liking: Welcome the infamous HTML component, because some marketing guy will have a fancy campaign online within 2 days...
EDIT (As requested some more detail to 1):
In many projects I have a rather generic page component with layout options (hide the navigation, hide or show a teaser column, etc.) in the page properties. The most common used options have a separate template for the author to choose. So the underlying page component is the same for the templates but the preset layout options are specific to a template. I hope this clarifies it a bit. Else please create a seperate question as Dave suggested anyway and be a bit more precise of what you need to know.
I am looking for an easy way to allow visitors of our Drupal 6-based website to filter all displayed obejcts globally by a tag from a given taxonomy ("featured topics"). This way a user could eg. select the tag "marketing" from a drop-down-list, which is located somewhere near the navigation, and the system would filter all pages, lists and views by the selected tag, across the session, until the user unsets the filter. Having a filter set should be reflected by the theme, but that would be the next task, I guess.
Does anybody know a module which does something like that or could help me here? Is there any easy way to get this functionality (without hacking my way deeply through drupal's guts in weeks of hard work)?
Thank you in advance!
Daniel
There are literally hundreds of modules that offer "filter by tag features". I am not aware of one that does what you wish as turnkey, but I am confident there is one that has exactly your interface and workflow, either OOTB, or configurable.
If you were considering views (you were, weren't you?) views offers so called "exposed filters" which allow any filter (filters being: created by Foo, edited after 24-dec, or _has tag Bar), where your users can select such filters from e.g. a dropdown box.