By jergason on
I am working on a module that adds a button to a node. It is nothing fancy, but I would like the button to take the user to a specific url when clicked. I saw a way to do that here: http://groups.drupal.org/node/35844 but it relies on Javascript to get the job done.
Is there a way to add a button to a node that will just go to a link when clicked?
Comments
If you don't want to do it
If you don't want to do it client-side, then you do it server-side with hook_form_alter.
Add a #type=button element, and attach a #submit callback handler to it that does what you want, eg call drupal_goto().
Or it would be easier to just make a link that looks like a button if all it does is go somewhere and doesn't actually do button processing.
.dan. is the New Zealand Drupal Developer working on Government Web Standards
That will only work for a
That will only work for a form, right? What if I just want to add it to the node?
hook_nodeapi() $op == 'view'.
hook_nodeapi() $op == 'view'. Add your button there.
Contact me to contract me for D7 -> D10/11 migrations.
Please post your code and spell out your requirements
Hi,
You've referenced a thread which discusses "I'm looking for a way to add a button to the end of a node that actually does something.". Therefore, you are implying that you have some sort of specific functional requirements.
If you have specific business requirements, please post them. Take the time to detail the requirements. Please explain what "add a button to a node that will just go to a link when clicked?" means???
Finally, you have stated that you are "working on a module" . Please post your code so that we can reference the details. Please document each section and explain how it fits in to your specific functional requirement.
You can also probably
You can also probably simplify the problem by using a link styled as a button. That means you can do it at the theme layer, either node.tpl.php or if content specific, node-content_type.tpl.php
+1 on this. if the button do
+1 on this. if the button do only link to page (without querying sql) then nevets way is the fastest and easiest to do.
--------------------------------------------------------------------------------------------------------
if you can use drupal why use others?
VicTheme.com
use preprocess_node
from your module this is one way to add link
other way:
step 1
step 2
in node.tpl.php add