Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By lucavox on
Hello ,I would like to know if there is a way to do the following:
I have a type of content [EVENTS], each node is created an event, in the node there is a button that calls an entity form to join.
I have to find a solution to prevent users who carried out the form when they return in the node chosen to not display the button.
I had thought of using Flags and Rules, but I'm seeing difficult.
Do you have any idea?
Comments
How are you adding the button
How are you adding the button to the viewed node?
rules flag node by saving submitt
No I know the button to add! :-)
I would have thought to add if the php code to show or not show the button (which is a div html).
I can not understand that discriminating use, so I thought to form flag. The user submitting the form, by rule selected as the preferred node then in 'I could put in "if the node is preferred not to show the div.
Without knowing how/where you
Without knowing how/where you adding the button it is hard to make a concrete suggestion. It sounds like you are doing things the hard way though. There are modules for signing up/subscribing to a node. And if you just want to flag the node, you can use the flag module which can be configured so for each person it for example it might initially read "Make this a preferred event" and once flagged by the user it might read "Remove from my preferred event list"
you are right
the function of the button in the events--node.tpl.php is:
in this way call up the form. In the entity form I created two hidden fields which are populated by the token (default value)
This way I have a new submission with the fields that indicate to me that node refers the form.
Now I stopped, I occorerebbe find a solution on how to prevent (once the user has submitted the form) that the user submits again the same node
Instead of placing that in
Instead of placing that in events--node.tpl.php I would place it in YOURTHEMENAME_hook_preprocess_node() something like
You will need to replace YOURTHEMENAME with the name of your theme.
And replace your current html/php in event--node.tpl.php with
<?php print $event_status; ?>
It would be a better practice to replace the inline styles (align="center" and style="text-align: center;") with css classes and use css to style
A better approach would be to implement a module that implements hook_node_view() and hook_templates().
hook_templates() to declare a custom template that will implement the chunk of html and hook_node_view() to use the template to add to $node->content. I would also use the Drupal form API instead of the hand coded form.
thank you!
Thank you so much
Now I try to implement it!
Server Error
This code http error 500 :-(
Button hidden
You can make a chosen button hidden or disable when the users click and finish creating an event. And at next session the button will display again.
but conditional
is this was the initial idea, but I have a condition (I think) to do so. and that's why I thought of the flag.
if you (and this I do not know how to do it) flagga the node, then the php code (for a new session on that node of the same user) hides the button (well I create an if that controls whether that node for that user was flagged)