Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function MYMODULE_preprocess_node(&$variables) {
- $node = $variables['elements']['#node'];
- $flag_link_service = Drupal::service('flag.link_builder');
- $flag_link = $flag_link_service->build($node->getEntityTypeId(), $node->id(), 'YOUR_FLAG_MACHINE_NAME');
- $variables['flag_link'] = $flag_link;
- }
- If ($user->uid) == 0)
- {
- redirect to login
- {
- else
- {
- {{ flag_link }}
- }
Add Comment
Please, Sign In to add comment