Reviewed & tested by the community
Project:
Type-local nids
Version:
7.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Feature request
Assigned:
Reporter:
Created:
1 May 2008 at 12:36 UTC
Updated:
15 Jul 2011 at 15:47 UTC
Jump to comment: Most recent file
Comments
Comment #1
ausvalue commentedI have created views integration for the Type local nids module. This is only for Drupal 6 with the current Views 2.
Integration of the type_local_nids was reasonably simple but both integration and usage of information on how many nodes there are of each type gave a lot of complexity.
A1) Usage for Local nids
For normal usage within Views you would start by clicking on the Add tab. You have a number of Type options here. Normally you would select 'Node'.
When you initially go into the edit window of Views and add fields you will have extra fields available under the group Type local nids. You would normally just use the lnid field.
A2) Usage for reporting number of nodes of each type
Since Type local nids contains a database table that effectively gives the total number of nodes for each node type, I would expect this to be useful information for reports etc. I have attempted to add this into the views integration but it caused some problems. The table relates to the Drupals node_type table but this table is currently not integrated in current Views implementations. Consequently, attempting to integrate this information into Views required integrating most of this table as well.
Usage is different to that for Local nids.
When you click on the Add tab, included at or near the bottom of the Type options is a new type called Node type. Select this. When you initially go into the edit window of Views and add fields you will have fields available from the Node_type table along with next_lnid from the node_lnid_next table. The next_lnid is the number that will next be assigned for the local nid of this type. It is one greater than the number of nodes of this type.
Yes, it would have been better to have already subtracted one from it but (I presume) this would require writing a new handler and I have already spent too much time on this and I'm not sure if anybody wants it.
B) Implementation
For the tables defined by the type_local_nids to be understood by the views module you need to create a type_local_nids.views.inc file that describes the table and its relationships to the rest of the database. In order for views to know that this file is to be loaded you need to implement the hook_views_api by adding the following function into your type_local_nids.module file: You just need to copy the function (not the opening and closing ?php tags) into the bottom of your type_local_nids.module file.
Below is the contents of a type_local_nids.views.inc file that will allow you to create views for Drupal 6 with Views 2 that include the Type local nid module information: Copy all the below, including the opening ?php tag but not including the closing ?>, into an emply file. Name the file type_local_nids.views.inc and store it in the same directory as the type_local_nids.module file.
Hope this helps
Ken
www.ausvalue.com
Comment #2
HoKe commentedgreat! it looks, it works pefectly. it is exactly what i was looking for, Thx it helped o lot
HoKe
Comment #3
keesee commentedSweet. Great work! Will test this evening.
--
J.
Comment #4
jbrown commentedThanks AusValue
I don't think it is a good idea to have {node_type} fields exposed to views and it certainly shouldn't be a part of this module.
Also what is the point of exposing the next lnid to views?
Can you create a patch that just exposes the lnid?
Comment #5
thekevinday commentedThis patch works well, but for convenience purposes of anybody else, I put it in patch form (attached).
I do not know what to do to make #4's request happen so I leave that to whomever knows how.
FYI, after applying the patch make sure to clear the system cache so that the local node information will appear in the views interface.
Comment #6
psynaptic commentedViews integration is critical.
Patch does need a bit of work but it works for me. Reformat the code comments and commit.
Comment #7
andypostSubscribe
Comment #8
tommychrisSubscribe
The patch in #5 is nearly good for D7, one exception (change views API version to 3 from 2):
Comment #9
arski commentedseeing that you switched this to 7x - will you still commit a fix that accomplishes this to 6x as well?