views:

617

answers:

2

I know the ideal place to ask is at . I posted my question in the drupal support forum and under the nodecomments module as an issue. I have also consecutively posted this question once a day for the past 3 days in the drupal support IRC channel.

No answer.

Hence, I have decided to try my luck here. I am running on the current setup on shared hosting for testing purposes:

drupal-6.12
fivestar-6.x-1.15
nodecomment-6.x-1.2rc2
cck-6.x-2.3
votingapi-6.x-2.0-rc2
views-6x-2.6

I followed the instructions in http://drupal.org/node/234681 even though the modules they used were a bit outdated. I got what I wanted working. I have a product node type and a review node type. Then I used nodecomment so that the review node type appears as a comment for product.

So far so good.

Now when I go view the review node by itself, I cannot find the link back to the product node -- the parent of the review node. I tried searching and came across this patch, but I am not sure how to use it. in fact I am not even sure if it solves my issue.

I don't mind having the parent node (the product node) appear as a breadcrumb, so long as there is a link back to the product node. I bought the "Using drupal" book, but I dislike the way it taught you to select a list of products in order to create a review. I tried searching for some time and came across nodecomment, node hierarchy and node relativity. After much experimenting, i have settled on nodecomment, but I need the parent link.

Please advise.

+2  A: 

The patch you were pointing at is for the 6.x-2.x-dev version (what's going to be nodecomment 2.0 for Drupal 6 someday), and is thus of little use in your case, sorry.

You could simply do something like

<?php print l('Back to product', 'node/' . $node->comment_target_nid); ?>

in your node-comment.tpl.php to get a link back to the product.

If you want to do more advanced stuff (like load the product node to get its title or other attributes), I'd suggest you make a preprocess function in your theme (or even create a module, depending how great your needs are).

Here's a good resource on preprocess functions: Setting up variables for use in a template (preprocess functions).

mikl
hi mikl, thanks for your reply. i tried this already. but it didn't work.<?php print l('Back to product', 'node/' . $node->comment_target_nid); ?> Any idea why?
keisimone
Hard to say. It works for me :)
mikl
thanks for reply mikl. i have to say for the sake of learning i would at least like to make your solution work as well.can i ask where EXACTLY you placed that line in the node-comment.tpl.php? <div class="content"> <?php print $content ?><?php print l('Back to product', 'node/' . $node->comment_target_nid); ?> </div>i put it here. in fact, i tried a few places as well. not working.
keisimone
Well, the position shouldn't matter, since the variable is available anywhere in the template file.
mikl
then all the more it is weird that it didnt work. the file i changed is sites/all/modules/node-comment/node-comment.tpl.php that is correct rite?
keisimone
No, if you're changing template files, you should take a copy and put it in your theme's folder to make sure it has precedence :)
mikl
+1  A: 

You may be able to adapt the method in this tutorial to your needs: http://www.lullabot.com/articles/photo-galleries-views-attach

Instead of using nodecomment, have a 'review' content type with a CCK nodereference field to the 'product' node (nodereference URL will add a handy link on the product node to the add review form with the product node reference already set). The node reference will appear as a field in your review node with the name of the product linked to the product's node.

Views Attach will allow you to add a listing of reviews to the product node.

GApple
wow! thanks GApple! to think that the using drupal was written by the lullabot people. why didn't they use the nodereference URL method in that book in the first place?anyway, even though i have not fully tested your solution due to lack of time but i think this is exactly what i am looking for just by looking at the video!you have any other good resources paid or otherwise i should look at for someone like me in learning drupal?i know little php and drupal but i know asp.net. I am building a review site that allows facebook connect.
keisimone
Using Drupal was published in December, and the Views Attach and Nodereference URL modules only had their first releases in January.I'm pretty new as well. Using Drupal was a great start and introduced some very helpful modules. I'm in the middle of Pro Drupal Development, which looks like it will be a great reference, but I've had little time to put it into practice so far. The Lullabot video and podcasts have some helpful info on best practices too.The best thing for me has been to just experiment, most things are hard to irreparably break.
GApple
what other books or resource you recommend for themes?
keisimone