Drupa 6: Adding a relationship to a Custom Module via a CCK content field in Views 3
Recently, I've been taking my first plunge into the world of custom coding for Drupal Views, with version 3 of the views module and Drupal 6. I've been doing various things such as trying to expose a custom module's database table to views, and establish relationships between my custom table and existing parts of the site in question, and it is this aspect of views that I am going to focus on with this post.
Usually, when setting up a relationship or a join in Views, you will be associating with something like a node or a user, one of the core system elements of Drupal. In this instance, it was a little bit more difficult. My custom module needed to have a relationship with a CCK field, which then (obviously) has a relationship with a node. So it was a three stage relationship (Custom module -> CCK Field -> Node), but the CCK -> Node part would be handled by Drupal for us.
A few things were required to make this work properly:
1) My custom database table had to be declared as a base table for views. A relationship can only be established with a base table, and this is something very important to bear in mind. A snippet of how to do this is included below:
$data['custom_table']['table']['group'] = t('Name of your custom table'); $data['custom_table']['table']['base'] = array( 'field' => 'your_custom_field', 'title' => t('Field description'), );
2) The required fields from my custom table needed to be exposed using the standard module_views_data hook. There are tons and tons of examples of these so I won't include one for now.
3) We needed to declare a relationship on the CCK field to create our relationship. This was done with a _views_data_alter hook, like so:
/** * Implements hook_views_data_alter(). */ function custom_views_data_alter(&$data) { $data['node_data_field_custom_field_name']['field_custom_field
_name_value']['relationship'] = array( 'base' => 'your_custom_table', 'base field' => 'your_custom_key_field', 'relationship field' => 'your_custom_field_for_relationship', 'handler' => 'views_handler_relationship', 'label' => t('Description'), ); }
4) Be careful with the naming in this hook, I got stuck for ages because I wasn't using the right naming conventions and only cracked it when I went into XDebug on this hook and was able to see all the available field names and the properties of the field, so you may need a PHP debugger of your choice handy for this.
This may not get you exactly to where you want to be but hopefully it will be of some use as I struggled for days with this (including a lot of fruitless googling), so if this helps even one person who accidentally stumbles across this post I'll be very happy.
I've spent a lot of time learning about this, and also once again bugging the guys in the #drupal-views IRC channel, and once again a couple of them must be thanked so a big thank you to damiankloip and dawehner.
P.S - I imagine a fair amount of this if not all is also applicable to Drupal 7, but I haven't tried it out yet.
1170 Comments
Custom module via a CCK content
Thanks for the help
Its relationship
Relationship Device
check my thesis
Set options for the fiveStar vote display by using the pulldown menus to select your choice for star display style, text display style, teaser display and full node display, and check the appropriate box if you want to allow users to retract their votes. Thanks.
Good
Great
house cleaners edinburgh
bloghostingproviders
lemondtrainer
foodnutrition.eu
educationmagazines.eu
masculineshopping
Drupa 6: Adding a relationship to a Custom Module via a CCK content field in Views 3
hush puppies shoes
hush puppies shoes
Nice Post
Excellent blog you have here
Very good blog
Educational Passion
Concrete Posts
Info
Great drupal training
Nice post!
read gamis murah berkualitas
gamis kaos murah berkualitas
baju gamis online onlen
obat tradisional darah tinggi online
obat herbal darah tinggi yang alami
obat herbal hipertensi murah
modifikasi motor beat
jual batik
jual gitar
jual gitar
gitar murah
impressive.
great Post
mebpersonel
mebpersonel
haberler
Article Directories
great Post
great Post
great
no addiction
slim 24 pro
atrie krediti
Drupal News For You
kiirlaen
kata kata mutiara kehidupan
puisi tentang cinta
cerita lucu singkat
kata mutiara lucu
I was Unaware about This
graet Post
excellent info
thanxs
great post
very nice
http://citycentreretreat.com/
Marvellous Sharing Must Say..
autopartstores
businessfinancenews
byersauto
kidsandparentscare
leasefinance
http://www.autovalues.org
http://www.besthealthinsuranceguide.org
http://www.carsforsell.org
ggh
This subject has interested me
Uk Locum Doctors
nice info
nice info
SAT Login
Nice Sharing Must say..
Riteway Moving - Alberta Moving
jassiac
terry jones
andrew jack
digiplexdest
Actually I am not habituate
Selain itu ada
black belt blueprint
Great
Togel
Togel Hongkong
TOgel
See more
nice info
Keluaran togel
awesome post
repairs
mind
strobin
great
nice blog
thanxs for sharing
excellent blog
impressive
thought
St George Utah Home Builders
mind
wordpress seo management
Concrete Staining
Trade Marketing
willliajm
dragon city cheats gems
meniu nunta
ssss
winning the one robert ford method
DGGP
Guar Protein
Gp11
kitchen appliance packages
Great tips
CCK form
mind
http://www.asiaboutiqueresorts.com/
http://www.hotelsinzanzibar.com/
Ranjish
dude
this is
davidjohn
About National Benefit Authority
acompanhantes
дизайн ÑÑ‚ÑƒÐ´Ð¸Ñ Ð¸Ð½Ñ‚ÐµÑ€ÑŒÐµÑ€Ð°
Email Marketing
Guaranteed Signups
go ahead with site
toronto movers
drywall contractors
How to be Rich
Just Thinking
impressive
www.rebelmouse.com/tao_of_badass/
Nice Information
http://circle.co.nz/
cibi
cibipublicom
sitewebcraiova
showroom
eurocort
fitness
nacele
http://www.youtube.com/watch?v=ptpnJY1Kaks
Virgin Media contact number
duncomet
How to be rich
CreatineHub
Courier
Fashion Brands Outlet
good
http://datasoftrecovery.com/
cpanel
vps
tjsjs.com
Indicizzazione Google
Thanks for your time so much for your specialized and effective guide.
I won’t think twice to endorse your web blog to any
person who needs guidelines on this issue.
pama
rfguoig apmzjpx
http://www.daspresidenthotel.com/
eavmjwv kgpomua
xreczqw sexraal
zrllqsd gvqquvs
No Win No Fee Accident Claims
vmpdzpw ahcimgc
Medical Negligence Solicitors
pensiunea daniel
breaking news today
My comment
fcbaopm ysdwuhl
ixmdoij fqlnofl
Height Growth Supplement - Step Up Height Increaser
Height Growth Supplement - Step Up Height Increaser
truyen nhan autula
rgxidae ldanvki
vkzogcg bzmhqix
xehoavd lrcspsi
vrmdzmz asofqhh
free copy scape
etzxbyv jwsdvdb
Usually, when setting
forum
Real Estate
Rear
Il ya des milliers de personnes jouant le jeu de tous les jours et de défense, parmi tous les peuples il ya des gens qui achètent basique joyaux de la monnaie dans le jeu pour accélérer les bâtiments, vous procurer des ressources eux beaucoup plus puissant que "joueur normal" faire.
Perfect Quality Essay Writing Services
best workout for weight loss female
computer essential for business
computer essential for business
Great work great people
great
great
Personal Trainer München
best way to get out of the friend zone with a guy
facebook hacker
how to be rich
High Pagerank Backlinks
High Pagerank Backlinks
i agree
best diet for nonalcoholic fatty liver disease
acompanhantes de sp
jack
careful
Hello,i really like your website design... its great... petroleum engineering schools
thcservers
Drupal vs CCK
Hello,i really like your website design... its great... petroleum engineering schools
hi do you know we can lose weight by simply cut through our food intake? by the way nice design of your website... Fat Loss Factor Review
by the way nice design of your website... Fat Loss Factor Review
serrurier paris
serrurier paris
High Pagerank Backlinks
nice
davidjames
Good One
nelsa
jackson
jackson
davidjames
good
good
great
davidjames
davidjames
Good one
Kolpe
secrets you have got. And definitely, I’m just always astounded with all the tremendous concepts served by you.
My opinion
Could you explain me the last point?
home warranty texas
http://www.mattressjournal.com/tempur-pedic-sued-over-vocs-memory-foam-safety/
Nice information
manager
yhks
http://prediksibola1.com/
manager
evolution marketing
asvab study guide
thanks for the information
jason
Hi top information in your website and content is updated also. good Fap Turbo 2.0 Review
restore my vision today
Gary Deardorff Cholla District
comment on form
drupal 6
asadalikhatri
asadalikhatri
darryl
Teds Woodworking
Google Sniper 2.0 By George Brown
Google Sniper 2.0 By George Brown
Great post this one
how can i get him to do what i want
oprah tempurpedic
Recruitment
asadalikhatri
Old School New Body Pdf
Free Movies Online
Text The Romance Back
freze tabla motor tamiri
phen375 customer reviews
phen375 customer reviews
where to buy meladerm
South Africa Latest News
cold stone creamery franchise
Husqvarna 236
Capture His Heart
best way to get any girl you want
buy facebook fans
Worldwide News
Amazing work
Thank you for sharing this
amazing post
jack
asadalikhatri
best keyword tool
asadalikhatri
Best Mac Pc Computer Repair Services Jupiter
asadalikhatri
asadalikhatri
sohail
asadalikhatri
jack
zeeshan1
tre residences at geylang
I noticed
Jump Manual
Reverse Your Diabetes Today Review
Truth About Abs
zeeshan1
Renegade Diet Book Review
Ultimate Herpes Protocol
Peyton Manning Wallpaper
what to do after no contact with ex girlfriend
text to make your ex want you back
Venus Factor System
text to make your ex want you back
Boost Your Bust
auto title loans richmond
Amazing Post
The Tao Of Badass Review
Evlilik Yıldönümü Hediyeleri
asadalikhatri
Harga Processor
Good
asadalikhatri
qmobile noir z5
jack
zeeshan1
on Aug 7, 2014
Trying to say much appreciated won't simply be sufficient, for the fantasti c clarity in your written work. I will right away get your rss channel to stay educated of any redesigns.
https://www.rebelmouse.com/tedswoodworkingpackagereviews/
Everything comes is a manner
Amazing Post
jack
asadalikhatri
asadalikhatri
Mobile prices
asadalikhatri
assafasf
diy trick photography
ayakkabi
sandviç panel
tabela
jack
asadalikhatri
jack
BlogHuts
Cellex-C
asadalikhatri
sdad
This is really
Good post
Wonderful
Tremendous
franklin7
Amazing Post
asadalikhatri
assdvf
adsgfhf
franklin7
Qtab Q300
amazing post
asadalikhatri
asadalikhatri
sdgf
asdsa
asadalikhatri
Hiii
franklin7
Zevi
mobile prices
franklin7
asadalikhatri
franklin7
Content Construction Kit (CCK)
franklin7
asadalikhatri
80s band
franklin7
franklin7
franklin7
asadalikhatri
franklin7
I was extremely satisfied to discover this site.i needed to thank you for this extraordinary read!! I doubtlessly getting a charge out of every last bit of it and I have you bookmarked to look at new stuff you post.
franklin7
zeeshan1
ok
I am impressed by the details that you have on this
web site. It reveals how nicely you understand this subject.
Bookmarked this web page, will come back for more articles.
You, my friend, ROCK! I found just the information I already searched everywhere and
just couldn’t come across. What a perfect website.
franklin7
top mac pc computer repair services singer island
caryhani@gmail.com
franklin
SEO services Hyderabad
preschool math
asadalikhatri
franklin
nice
kiosque theatre paris
Diwali Wishes
but you must give it initial boost and i know how to do it, just type in google for – wcnu
traffic increase
Diwali Wishes
Diwali SMS In Hindi
Diwali Wishes In Hindi
Diwali Quotes In Hindi
Diwali SMS In English
DIwali Wallpapers
Diwali Pujan
asadalikhatri
www.garciniacambogianmexico.com
asadalikhatri
franklin7
Wonderful article
I bookmarked it.
asadalikhatri
Gret article
can aid me. Thank you
festkokkeriet
useful reference
Boca Raton SEO
zeeshan1
amazing post
asadalikhatri
franklin7
Everglades Fishing Guides
patio offset umbrellas
Drug Rehab NJ
franklin
asadalikhatri
franklin7
franklin7
amazing post
Jammer good
it has aided me out loads. I hope to give a contribution & aid
different customers like its helped me. Good job.
fen
in features also. Keep functioning ,impressive job!
D45
can i subscribe for a blog website? The account aided me a
acceptable deal. I had been a little bit acquainted of this
your broadcast offered bright clear idea
franklin7
Naturally
Basically Excellent. I’m also a specialist in this topic therefore I can understand your effort.
asadalikhatri
jack
effective home remedies for genital herpes
franklin7
test ok
What may you recommend in regards to your publish that you simply made some days ago?
Any sure?
franklin7
Nice
amazing post
franklin7
asadalikhatri
asadalikhatri
asadalikhatri
franklin7
asadalikhatri
jacksonman
amazing post
amazing post
asadalikhatri
franklin
asadalikhatri
1
drupal
franklin
www.evolutionslimmingdiscount.com
Dining
He was totally right. This post truly made my day. You can not imagine just how much time I had spent for
this information! Thanks!
asadalikhatri
franklin
asadalikhatri
jio
by Ambrose Bierce.
roblem with the code
amazing post
asadalikhatri
frem
is the market chief and a large section of folks will miss
your wonderful writing due to this problem.
I have read a few good stuff here. Certainly price bookmarking for revisiting.
I surprise how a lot attempt you put to make
this sort of wonderful informative web site.
asadalikhatri
semperkei
it has aided me out loads. I hope to give a contribution & aid
different customers like its helped me. Good job.
module
the post.
tj 34
now not really much more smartly-preferred than you may be right now.
sip 12
great written and come with almost all important infos. I would like to
see extra posts like this .
naturally like your web-site however you need to take a look
at the spelling on quite a few of your posts.
asadalikhatri
arft
recr
“He is able who thinks he is able.†by Buddha.
asadalikhatri
intelligent
me in my opinion consider it from a lot of various angles.
Its like men and women are not interested until it is one thing to do with Lady gaga!
Your individual stuffs great. Always take care of it up!alternativ.ca
Rosso Bianco
Wood Pellets
www.garciniacambogiaireland.com
asadalikhatri
www.decasteroidshop.com
grey
super writings. Past few posts are just a little bit out of track!
come on!
agas
super writings. Past few posts are just a little bit out of track!
come on!
asadalikhatri
jacksonman
fdg
Muscle and fitness
amazing post
amazing post
Koh Lipe
michael fiore text your ex back 2 video
script
drupa 6
hello 6
amazing post
Ft Lauderdale SEO
design and style
besides I conceive the design and style contains fantastic features.
my views
asadalikhatri
asadalikhatri
amazing post
asadalikhatri
cart
in features also. Keep functioning ,impressive job!
jacksonman
jojo
franklinadas
hii
info3
tenks joob.
nice
joker7
franklin
franklin
zeeshan1
blogging look easy
you make blogging look easy. The overall look of your web site is great, as well as the content!
jojo
American Residential Warranty | WE ARE THE HOME WARRANTY EXPERTS
franklin
jojo
jojo
asadalikhatri
asadalikhatri
asadalikhatri
aanrechtblad
asadalikhatri
loyal 9 complaints
franklin
asad
http://www.rebelmouse.com/mi40xtremereviews
Jujitsu
PHP. I have always disliked the idea because of the costs.
But he's tryiong none the less
logistics
jojo
jojo
hosted
zeeshan1
Motorcycle jewelry
Austin Garage Door Solutions
franklin
richy
asadalikhatri
asad
mi40x review
I am very new
asadalikhatri
richy
hello y
victor
leezajion
challenging
richy
richy
I'm very fresh
Prediksi Togel
awprvtt tnrembc
Reverse Mortgage Olympia WA
jojo
jojo
asid
richy
richy
I will be quite fresh
never
most yuo
I'm quite
amazing post
Locksmith
paypal hosting
https://www.youtube.com/watch?v=T9CJTsEa4ys
amazing post
asadalikhatri
website
earn more from adsence
Lyndon Johnson
richy
richy
richy
richy
richy
jackson
Merhaba
As a list of black leg protection or maybe that will skinny black complement try on some along with anything at all, simple fact is that common neutrality allowing it all to set with a lot of many other parts whilst still being not necessarily clash. ??? ??—?— In case presently there virtually any, remember the fact that eventually it may deform how we go walking together
evden eve nakliyat
güvenlik kameraları
you name
https://rebelmouse.com/mikefiorecapturehisheartreview/
asid
asid
asid
Excellent article
richy
honey
http://www.enriqueiglesias.com/profiles/blogs/girlfriend-activation-system-review-enrique-has-a-hottie-do-you
asid
asid
website
Good Post
mona
asadalikhatri
jualjamtangankwsupermurah
tokotaswanitabranded
website
Winning Sports Bets Known
Dating Today Help
www.rebelmouse.com/tinnitusremedyreviews/
https://rebelmouse.com/weightdestroyerreviews/
buy fifa 15 coins
عکاسی صنعتی
بلیط چارتر
چت روم
All in one kitchen reviews
asadalikhatri
asadalikhatri
cash for junk cars Detroit
beard grooming
Qmobile prices in Pakistan
Latest Dresses for Women
New Wallpapers HD
National Saving Prize Bond Result
BMW Auto Car prices
best veterans day quotes
asad
moona
richy
stronghold crusader 2 download
zeeshan1
richy
http://www.rebelmouse.com/amywatermansavemymarriagetoday
http://textyourexbackmichaelfiore.com/
http://textmate2.org/
http://theofficialwebsite.co/christian-h-girlfriend-activation-system-review/
amazing post
TBrown
zeeshan1
Pure Life Cleanse
tv antenna
asid
pris luis canas online
hello y v
application
king
greats
Forum
hi
party favors
king
https://www.rebelmouse.com/ultimateherpesprotocolreviews/
king
robot
jhon
adel
asadalikhatri
aerix
asadalikhatri
asid
rebelmouse.com/
https://www.rebelmouse.com/mi40xtremereviews/
https://www.rebelmouse.com/whatmensecretlywantreview/
https://www.beastnode.com/portal/knowledgebase/9/Basic-Minecraft-VanillaorBukkit-Server-Commands.html
interesting
https://www.rebelmouse.com/pottytrainingin3daysreview/
michel
tree
milk
Mikrotik
can you help about that ?
asid
asid
asid
asid
pk box office collection
toys
asadalikhatri
world
http://www.abaya-central.co.uk/
jojo
launch x431 gds
South Africa Has News
Web Design Zimbabwe
AkoiWeb Design does web and graphics www.akoiweb.com
asadalikhatri
personal trainer berlin
asid
fiverr
Shilajit capsules
subjestsss
Guess horloge online
Diesel horloges zoeken
fiverr
elance
web
HTTP://graniet-werkblad.be
Well Done
Amazing
Clash of clans hack
subjeasdst
website
website
fasdgah
Well Done
Well Done
Well Done
Well Done
Well Done
really
all right
asadalikhatri
madina
madina
madina
madina
asad
madina
https://rebelmouse.com/bobbyriomagneticmessaging
https://www.rebelmouse.com/michaelfioresecretsurveyreview/
asadalikhatri
subjeasdst
madina
Well Done
Well Done
Well Done
Well Done
Well Done
Well Done
Well Done
website
Alfonso Losa
kitchen cabinet doors
Hello,
unfinished cabinets
asid
https://rebelmouse.com/
madina
Déménager facilement et pas cher
Et pourtant ca parait simple pas besoin de bras de déménageur pour appliquer.
https://www.rebelmouse.com/texttheromancebackmichaelfiore/
check cashing in fresno online
website