I want to create a view that only shows the oldest and newest node of a certain content type what is the easiest way to do this? Thanks
This may be possible with hook_views_query_alter. However, for a code-less approach I would recommend creating two views. One view to grab the oldest and another view to grab the newest node for your content type. You can then use Panels to place these views right next to each other giving the illusion they are one.
This is the easiest method to do this with Views UI.
1) Create a views display (page, block etc) with filters of Content type and Published, limit it to display only One node and Sort by date published ascending. This will show the oldest node.
2) In the same views add an Attachment display. Use the same filters and limitations and change only (by overriding this display) the sorting to descending. This way you will get the latest node.
Related
I am using views 3 and drupal 7. I have a view setup where it will return all related articles based on the keywords which works perfectly.
The problem is that I don't want the article that I'm on to show up in the results. Is there a way to hide specific nodes from displaying? For instance, lets say I have nodes: 43908 and 43909 that I don't want to show up in the view.
I've added a filter criteria (not contextual filter) to remove these nodes, but is it possible to combine node ID's into one filter? So if I wanted to show all but 43908 and 43909 how would I do that? I've tried to add them as 43908+43909 but that didn't seem to work.
You can use the regular expression option for the nid filter. So for the nid you mention you would do:
[^43908|^43909]
This filters out nodes with nid 43908 and 43909.
As for the scenario you describe, I think a better approach would be to add a separate field to your content type, e.g. field_in_progress, a tick box only visible when editing. Then you can add a filter on that field for the view.
This article may help. It involves excluding the current node from a list view.
I want to create a view over a content type. Over this page I want a select list of Months to filter the content by month.
Is there any module or how can I achieve this by view?
The date module can do this however there is one small caveat. I do not believe this will work if you are using fields such as node created date or node updated date. This approach will only work for date fields that are added to the content type.
If you need to filter by node created or node updated date then you can either build a custom filter for views (which is not for the faint of heart) or you can possibly try this module http://drupal.org/project/views_daterange. I have never used the module but it sounds like it might do what you need (but is only released for Drupal 6).
I'm using Drupal 6.20, Views 2 and Views attach module to append few view displays to a full node view. Is there some way to reorder the attached views? The views should still be grouped together (ie. I do not want to insert any other CCK field between them), but I want to display them in different order than that they automatically appear in.
There's no easy way to do this through the GUI as Views Attach just displays the attachments in the order they were created.
You need to export the View to code (open the view, under "Export" tab) and manually move the attachments into the required order. You may need to update the attachment number too (ie. attachment_2 becomes attachment_1).
Re-import the View using "Import" - either under a new name or by deleting the old view before you run Import.
Take a look at Views 3.x which offers a UI to reordering displays. I just attached some screenshots at a similar question on SO.
I'm making a site wherein I want to show the current course that I'm gonna teach to my pupils.In this page there should also be links provided to my previous courses. Now when I'm done with this course I want to transfer it to a previous course or rather automatically create a link for it and get the new course content in it's place. I just think doing manually is kind of stupid. Rather I want to have a form where i can create my new course then click on make current course as previous and this course as new whenever i wish.How can I do this.Is this even possible
Pretty open question ... One way would be to work with views when showing a node.
In the view you should use a custom php field, which collects the record (nid) within the course-node table. And then create a link using the drupal path_alias function or by using node/nid ...
You could use panels-module as well. Where you have a view with the latest course, and under the latest course you have a view of a link to the latest course -1 . (I think you can set an offset in views to get the previous course) The view should accept an argument, namely the nid of the currently loaded node.
If you use this method, do check if your panels is giving the arguments to the views module.
Another way would be to use node reference as to what is the previous course (but you don't want it to be manual). The advantage of node_reference is that you don't need to enter your courses in a certain order. If you make it automatically, then the order in which you fill in the courses should be correct.
Easy man. Just create a content type called "course" and using CCK, add all the fields to capture information you want about the course.
Now you have the content. Using Views, create a simple view page displaying course content type and sort it on descending order, set it to display one item at a time and add a mini pager. That way the new course will be the first one displayed and the other ones will be behind it. You might need to customize the pager a bit ^^
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.