3

I have a site where 'related pages' is a node reference CCK field for a node. Authors can add related pages (1 or more) to a node with the autocomplete functionality of node reference.

My question is the following: is it possible to extend the CCK node reference field to include non nodes, e.g. views pages, in this case?

4

You could use a separate viewfield for the related views, and theme it so that the nodereferences and viewfields appear in the same list.

You could also use a link and use a custom widget if you don't wanna type the full path every time.

On a couple of sites I ended up never (or very rarely) using a view's page display. Instead I attached the view to a node, and always referred to the view via its node. This was because my advert banner system was based on nodereferences. It's not the most extensible approach, but it worked for those sites.

| improve this answer | |
2

There are some major differences between a node and a view. The node is some pieces of data (title, CCK, etc), while the view is constructed by querying the database.

That said it would be possible to make a reference to views. I don't think the approach would be to try to extend the node reference field. Instead you would need to create your own type of CCK field. Unless you know your way around CCK, this could very well be a lot more work than you would like.

You also need to note, that views are more complex than nodes, as they have more viewing possibilities. A view can have an endless amount of different displays, so you would need to not only save the view name but also the display.

The solution would probably end up being so technical, that only expert users would be able to use it. Though I'm against using PHP filter in node, an easier solution would be to create a field, where you could put in a PHP snippet to embed the view you want. views_embed_view I believe it's called, this is what you would have needed in your cck field formatter anyways.

| improve this answer | |
  • I agree. Altering the module to include also views is quite difficult; a node reference uses the node ID as reference, while a view reference cannot generally contain a node ID. – kiamlaluno Mar 30 '11 at 6:11
0

Just adding another solution as @wiifm was looking to only use the nodereferences as hyperlinks. Linkit module + Links + Linkit Views gives a field with a pretty little search widget as well as a WYSIWYG button + IMCE integration.

One config thing to check in my answer re Views Links (to my own question) on configuration.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.