I am a drupal newbie, but quickly learning. I can see the potential power now of CCK & views, if I can only get them to work ;)
I am using drupal 6.14, content 6.x-2.5, views 6-x-2.6
I have two content types: lets call them course and instructor. Each instructor has a CCK noderef (multiple) to the courses he is qualified to teach. On the course pages I would like to present a view of all the instructors that can teach that course. I have read advice on this site, and many sites, and have tried to set up the view the way people suggest, but to no avail.
Here is my setup, and I'm not sure if this combination is affecting my results:
- my course content type is a normal drupal content type, but the instructor content type is actually held within a 'profile as content' content type.
- I am using pathauto to generate all my paths. my courses are aliased to course/[title-raw] and my instructor profiles to profile/[title-raw]
- I am trying to use a views block to be placed with the body of the course page, and as far as I can see, I am setting it up according to what I have read online here:
I have built the default view, and have added a block view based directly on the default without mods or overrides:
For relationship, I have specified the the noderef from the profile node type: content/teaches, required, and delta-all
For arguments, I have specified (teaches) node id, upon failure provide default argument, node id from url, basic validation
For fields, I have specified content fields from the profile content type.
I am not doing any special sorting
I am not doing any filtering at the current time - earlier i tried to limit to node-type: profile & course but this made no difference. Once I get results I will add filtering back.
I have enabled the block.
In the live view, if I enter the node id of the course, I get what I require, a list of potential instructors for that course, but when I go to any of the course pages, the block does not appear.
As a temprary debug test, I have tried changing the default argument to a default value of 3, to insure that the block can truly be generated, and indeed, the result is that the block appears on every course page, but showing who can teach course '3'. But switching back to using 'node id as url', the blocks disappear.
So I suspect my problem is related to 'node id from url'.
Any ideas?
P.S. I can provide more info, but please tell me how to generate it, since, as I said, I'm not all that familiar with all the features drupal provides.
Thanks
Comments
Comment #1
merlinofchaos commentedFirst: Thank you, so much for filing such a concise, well detailed, legible support request. I cannot express how rare it is to find a request that provides an appropriate level of detail.
Sadly, I do not have an immediate answer to your problem, but I can provide you with a couple of steps to see if we can figure out what's going on.
In the argument validator for your block, set this to PHP code. In the code textarea, enter this:
(Don't use the PHP tag, I just included that so Drupal would properly hilight the code).
That will first tell you what default argument it is actually coming up with. This might give a clue as to whether node ID from URL is failing entirely or not. If it is failing entirely and providing no value at all, try:
That'll tell us what the internal URL is, ignoring aliases. It *should* be node/NID from your descriptions, but I can think of absolutely no reason why Node ID from URL would be failing at that path so I'd like to verify that the assumption is correct.
Comment #2
dpatte commentedThanks for your response :)
On trying the 'node id from url' with the php codeline 'drupal_set_message($argument); as you suggest, I get the following error:
recoverable fault error: object of class views_handler_argument_node_id could not be converted to string in (my path)\theme.inc on line 1127.
I then reverted back to 'node id from url', and also did some other experimenting as follows, which may give some other hints as to the problem:
- i added the field (teaches) Node-Id to my field list, and the live preview shows correct course node ids as well the profile fields. So the relationship and noderefs processing seem to be ok for fields.
- interestingly, I changed the 'what action to take if argument does not validate' to 'display all values'.
(ed: see posting 4 - the following was not quite correct)
Comment #3
dpatte commentedI have now tried your second code suggestion..drupal_set_message($_GET['q']);
the liveview reports: admin/build/views/nojs/preview/StyleInstructor/default
the course pages report: node/3 or node/26 (as I would expect), but the blocks still dont show up.
As an aside, if you are wondering why my view is called StyleInstructor, instead of perhaps CourseInstructor, its because the site is for dance courses, and the courses are listed by dance-style name. Oh, and no, there are no Polka-style, or mosh-pit-style pages, yet. :)
Comment #4
dpatte commentedlet me correct somthing i said in posting #2, last few lines. It should say that with 'show all fields', the instructor blocks DO appear on my course pages, but they always list all instructors, not just those for the particular course. so its always falling into the 'does not validate' situation.
Comment #5
Lanae commentedFor dpatte, this sounds very similar to something I want to do. Just yesterday, I noticed this module, which looks like it might do what we want:
http://drupal.org/project/views_attach
I haven't had a chance to try it yet, but I will soon.
Comment #6
dpatte commentedI have further details of the symptoms in the above case:
When using the argument (Teaches) Node: Node Id:
1) If I use 'display all' on not present: it displays all profile records on each course page, but
2) If I use 'use node id from URL' on not present, and then say display 'all' if does not validate, it displays no profile records at all on the course pages.
I have some PHP experience, from years ago (I did a small amount of PHP programming in 1999 - but nothing significant since then). I'm willing to try to poke around in the code that fails to recognize the node id (both the default 'is present' case and when using 'node id from URL if not present' case), if you can point me to some of the code that processes these cases.
Comment #7
dpatte commentedRESOLVED
I also had the module 'Node Heirarchy' 6.x-1.2 enabled. Disabling 'Node Heirarchy' solves the problem.
It seems that node heirarchy, when enabled, prevents views blocks from being visible on any content pages when 'node id from url' is selected for the view.
Comment #8
lauggh commentedI have a similar problem, but with the Node Hierarchy Children List Block view not showing up using Context visibility. I detailed out the issue here: http://drupal.org/node/608968
If Node Hierarchy needs to be disabled for this block to show up, what's the workaround for me to create children pages? Menu?
Comment #9
dpatte commentedWorkaround: I used node references, CCK, and views to build the equivalent functionality. I was using CCK & Views anyway, so it actually simplified things for me.
Comment #10
merlinofchaos commentedSounds like you got it sorted, then.
Comment #11
dpatte commentedyes thank you.