I have a menu item called "Products" which when clicked displays all nodes created by the "product" content type. Every "product" node has a file attachment field with a file attached.
If I click on a "product" node, it takes me to the node as expected and I can see all the fields on the node, including the PDF field:
I want to hover over the "Products" menu link, then see the different products as a dropdown in the menu and when a product is clicked I want it to NOT go to the node, but rather open the PDF attached to the node So instead of showing e.g /product/african-decor ... it must go to product/african_decor.pdf which is attached to the node:
There are a couple of ways this can be achieved.
You can use the Menu Token module which allows you to use various fields in your menu paths. When building the token pattern you may need to create an absolute URL using the [site-url]
token.
Also make sure the uses tokens
checkbox is ticked.
This way is slightly less elegant.
Assuming you don't want to actually visit the product content type and will always download the PDF, you can overwrite the template for the product
content type and redirect to the PDF URL.
You'd need to create
node--product.tpl.php
And replace the contents with
header("Location: " . $pdf_field);
// $pdf_field might be $node->field_pdf[0]['value'];
You can implemement hook_taxonomy_menu_path with a custom module an override the base based on the nodes associated with the term. In the callback, return the path of the attachment in the node.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With