In a module I am developing I wish to control display of a link in node's content depending on user's choice. I want to display this option to user(whether he wants to display the link on particular node) when he is on a path like this /node/{node}/edit with other options(menu settings, comment settings) available on that page. On doing some research I managed to find out that usage of field plugins would be required. This I am saying because comment module implements FieldType plugin and displays option of type open, close, hidden comments. But now I am not able to move further because I am not able to understand how will I keep track of option selected by user for different nodes. It would be great if any one can throw some light on this, some code or reference to similar usage by other custom module would be of great help. Thanks.


You don't need your own field types for this like comment adds.

You can use checkboxes, radios, lists, whatever you want that makes sense for you.

Moving them into the sidebar requires some form alter code in the node forms that moves them into fieldsets. path_form_node_form_alter() is an example that defines a fieldset and moves a field into it.

Then all that's left is custom preprocessing/twig checks.. check the value of those fields and then display whatever you want.

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.