Drupal cck and views - drupal

I have added a new content type event. Now, i have to make a view in which it shows a set of fields if the dateOfEvent (one of the fields) is less than the present date and some other set of fields of the 'event' content if the dateOfEvent is more than the present date. how can I do that in the views..
thanks in advance for helping...

Hmm... I think I'd do this in the theming layer. So in views, you would make all fields available, and then in the theme, you'd hide one set or the other depending on the date value. Whether to do it with views theming, or in the node_type.tpl.php file depends on how else you're using the cck types.

Following this guide should get you where you're going: Step by Step Setup of Calendar View

Are you using the Date module? It will add a bevy of new views options and make CCK date field easier to use in this manner describing exactly what you asked.

Related

Drupal: List recently modified pages

In drupal, I would like to create a page like a site map, but also containing last modification date of each page and preferably mod author.
To clarify: I need to last date the page contents have changed, so this could be a change to the template or the underlying DB. Clearly, changing 1 DB entry can effect many pages.
Many thanks
Last changed timestamp is stored in node table under changed column. You can get this information from here & display it in the teaser.
If you need more sophisticated change control then you need to enable node revisions: http://drupal.org/node/320614
If you are using the views module, create a view for a sitemap and make an alias /sitemap or something similar.
When you add fields in the view, you can select: "Content: Updated date" as one of the fields. Any time this content is changed, it will use that timestamp as the field.
I hope this answers the question. If I misunderstand your question, I'll try to revise.

CCK create custom non-standard field

I've created new content type. And I want add new custom non-standard field. The field should consist of two text fields. Let's say: double text field. Ex.: Product content type and I want to add features of product such as: weight, length etc(many features). First field is 'Feature' and the second one is 'Value of feature'. The question is: How I can realize such a field? Module, hooks?
You can create your own field pretty easily, you'll need a custom module and to implement a bunch of hooks like you suggest.
Rather than go through all of those here you'd be better off downloading the Examples module, and looking at field_example. I've based tons of custom fields off of that code and they've all worked perfectly. Plus the module is well commented and gives you good insight in to the way the field/widget systems work.
Hope that helps
One straightforward alternative is to use the Field Collection module

drupal-----add a field to the content type story

now, i want to add a dead time field(the style is 02-12-2010) to the content type story. how to do that, i used the hook_form_alter() and format_date(),but when i created a new article,and select the time.but the time can't show on the article's page.why?
Why don't try contributed modules instead?
A more elegant solution I think will be using the CCK module which provides the ability of adding new fields to content types (as well as creating new content types), you can install then the Date module provides you with the ability to attach date fields to content types.

Drupal Views of nodes to show node comments

I've encountered a Drupal problem: I'm using the Views module for rendering nodes of a kind, based on the user id of it's author (it is a Content Profile actually). I want the view to show the comments for the node, just like in node/%. I could not find any option in views or any relevant module. Am I in the wrong direction and should reorganize stuff for this...?
Any ideas, how can it be done?
Regards,
Laci
Using views is really not the best plan of action. You should instead create a node template in your theme and customize it. If needed you can put some logic in a preprocess function. It requires more coding but will get you where you want.
If you use view node display type
Check in it's settings show comments
if you use view fields display type
Use relationship to comments and select fields you need and theme them
I know this is old request, but I was just struggling with the same issue and came across this post. I thought it'd be helpful to share my solution.
I'm using Drupal 7, with Views 3 and Display Suite.
In your view, choose the display in question.
Under Format, click the first link to the right of 'Show'.
Choose 'Content' (or 'Display Suite' in my case).
Click 'Apply'.
On the next screen, you'll have the option to 'Display comments'. Check this box and save your view.
You should now see the comments displayed under each item in the view.
You could create a second view (with URL e.g. /comments/% where the placeholder will be the node ID, and not the comment ID) that lists comments for a given node, with a contextual filter to only show them based on the NID in the URL.
Then, add that view to the footer (as a 'view area') of the single-node view you've already got.
There's some tweaking required for layout (inline fields etc.) but the basic structure should work.

Drupal: Sub views?

I have a parent/child relationship (based on the cck node reference field).
Recipe Group contains a node reference to the type Recipe. It's a 1 to many relationship.
What I need to do is create a view that displays the recipe group information, and then under it, the recipes that have been assigned to it's cck field.
So
RecipeGroup1 - Title
Recipe1, Recipe2, Recipe3
RecipeGroup2 - Title
Recipe4, Recipe5, Recipe6
etc etc
I've created the view to pull the list of recipe groups.. but I have no idea how to retrieve the recipes that belong to the group?
I've tried googling, but we are on a tight time line and would appreciate any assistance.
Thanks.
Take a look at http://drupal.org/project/views_field_view. It lets you combine two views (groups, recipes), inserting the recipes view as a field into the groups view. Using this, you can have as many fields as you want for the group.
You can use the Views attach module to associate a view with a specific content type and display that view on that content type's node page.
There is a webcast here that demonstrates how the module can solve a problem similar to yours.
However, the webcast assumes your nodereference CCK field is on the child content type and is pointing to the parent content type, not the other way around like you have it.
Instead of using the nid of the recipe group as an argument to the view (as shown in the video) you may be able to use one of the recipe group's tokens (the nodereference field referencing its children). You can see that option at 9:32 in the video.
Whatever you decide to do, I think Views attach will likely be your answer.
Include the cck reference node field as an output field to your view. After, you can 'rewrite the output of this field'.. so that it looks however you want.
add noderefernce field in to views fileds
select check box to group field result in node ref field settings
theme that field as you want

Resources