Hi,

I have been searching the forums and sites for a few days now and can't find the answer to my specific question.

Basically I currently have two content types with the following cck fields

--Product
--Product Image //Image Field

--Promotion
--Promotional image //Image Field
--product refernece //Node Reference field to reference product the promotion relates too.

I would like to create a block using views that displays a list of Promotional Images linked to the product in the node reference field, I have tried rewriting the promotional image field as a link with [field_reference_nid] as a the replacement but this doesn't work.

You can see what I am trying to achieve and the problems I have on the following demo site.

http://c3443764.myzen.co.uk/

Thanks in advance Dan.

Comments

chunty’s picture

I have something similar: I have a page with an attached feature using a node reference and the feature has an image - on the page I then show the feature(s) with it's image in a block.

The key to doing this was when I built my view adding a "relationship" which was the node reference field between the page and the feature.

Then I select all the fields I want, node title, the image etc etc but for each one I tell them in the dropdown that appears an the top to use the relationship that is defined. That in turn results in the node title being the title of the feature and NOT the page.

I wish I could remember where the heck I first saw how to do this - it might have been a mustardseed media podcast here http://mustardseedmedia.com/podcast but I'm not certain

See if that helps

C

danharper’s picture

This is similar but the block I want to create will appear pretty much on the whole site and contain all prmotion nodes, It's getting the link from the node reference field and using it on the Image I can't seem to do.

I added a relationship but then when I tried to use it on the fields they just disappeared presumably because there was no node to link them to while previewing.

Cheers Dan

chunty’s picture

Hmmm so let me get this clear:

On any given page of a site (not particularly the actually page for the product) you want a list of all products that have a promotion on them where by the state of having a promotion is define by the fact that there is a promotion item linked to them.

You then want to list those product but showing the promotional image NOT the product image but with a link back to the actual product page.

Have I understood this correct?

C

danharper’s picture

It's the reverse,

Promotion is it's own content type with a cck image field and node reference field, the node reference field links to some page or product that the promotion is about.

I would like to list all promotional nodes in a block only showing the cck image field of that content type, the image should link to the node referenced in the node reference field.

Cheers Dan

chunty’s picture

I still think my method should work :)

If you can give me a login to your site I can try to create view that does this for you using the method I suggested - if you don't want to post here then use my contact form

C

chunty’s picture

I took a look at Dan's stuff and the steps I followed were as follows:

1) The stuff to be listed was promotion nodes so build a view that list all promotions (just use an easy field like title to start with)
2) Then we need the link to product that the promotion is for - so add a relationship using the product reference field on the promotion
3) Now we need some data from products - again just use an easy field - so add another instance of node: title but this time tell it to use the relationship, that results in this being the product title
4) Now you can add any other field you want from promotion or product

The key here is to start simple stuff using text fields and worry about images and links later cos then you know for sure its working. If you want stuff from the linked node (using the node reference) simply tell the field to "use the relationship"

The only other thing I needed to do on this which is specific to this example was to use the ability to re-write the output of a field to wrap the image in an A tag which liked to the Node: [Path] of the product so that the image for the promotions was actually a click able link to the product and not the promotion

C

RedTop’s picture

I love it when people are so kind to follow up on threads for future reference.

You helped me solve this problem and explain how views relations work in one go. cheers buddy!