Score:0

How do I make links from views to be opened in modal popups without adding custom rewrite?

hk flag

I was trying to find if there is a way to avoid writing custom rewrite for links to open in modal popups from a view.

Here is what I am rewriting a custom field for doing this now.

<a href="url/{{ field_value }}" target="_blank" class="use-ajax" data-dialog-type="modal" data-dialog-options='{"width":"60%", "title":"Popup title"}'>View</a>

The problem with this approach is that this would require me to do it in multiple views with the same rewrite for each of the links that need to be opened in a popup.

Wanted to know if I can do this without the rewrite being added for every field.

leymannx avatar
ne flag
I’m voting to close this question because questions explicitly asking to recommend, find or compare a module, theme, distribution, or other off-site resource are off-topic for Drupal Answers.
hk flag
Can you please direct as to how this question should have been asked? Or where else should I have asked this?
hk flag
I went ahead and rewrote the question to specifically address the technical problem.
Score:0
cn flag

You could write a custom field formatter that applies this, and then set that in the view instead of the manual rewrite. Either way, you are going to have to apply something to all of those links, no way to avoid setting that up initially.

hk flag
Couldn't there be a plugin to add an option in the field edit popup where you can simply check a checkbox to say "Open link in popup"
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.