Score:0

Is it possible to define the destination that Views adds to links?

us flag

Views has a field to create a dropdown menu and this has the option of having the destination added to those links. This works great. Unfortunately, if the View is used through an AJAX call the destination ends up looking like it should return to the AJAX call rather than the page which launched the ajax call. This core Drupal bug: https://www.drupal.org/project/drupal/issues/2866386 is reporting this issue in a slightly different use case than mine; and sadly, the bug is marked as CLOSED (even though technically it isn't).

My use case is using a modal form which upon submission, changes values in a block on that page. That block has numerous links in it which are using a Views dropdown. Within the ajax call i rerun the View and update the block on my page with the result of the updated view. Due to the issue mentioned above, the links all have a corrupted destination set.

Wondering if there is any way to set the destination that Views wants to use before i run $view->execute()?

Was hoping for something like $view->setDestination(); but no luck (I suspect since people think Views knows what the proper dest is).

cn flag
Bugs are off-topic for this site. If you have a reproducible bug report of an issue that affects core, it should be filed as a bug on drupal.org.
cn flag
If your issue is related to an already closed bug, you should open a new bug report and reference the closed bug report as a related issue. You should be as specific as possible in describing how the bug you found differs from the already closed bug report-- or provide evidence as to why the closed bug report should not have been closed.
No Sssweat avatar
ua flag
Maybe, as a work around, you might be able to fix those destination values via JS on ajax complete.
liquidcms avatar
us flag
@PatrickKenny, this is not a bug report. I thought marking the question in bold would highlight the question.
liquidcms avatar
us flag
@NoSssweat, ah, i see. Have js go in and modify all the links in the View. Yes, that's possible but i could also easily uncheck the "add destination" in the dropdown field in the View and manually create the link with destination for each field - but i was hoping for a way to set this for the view so i didnt need to handle each link on its own. Perhaps no way to do that.
liquidcms avatar
us flag
Would still be nice to have Views get this fixed or have a proper way to set the destination; but for now i sort of took a hint from @NoSssweat's answer and just did the same thing in php. Used preg_replace to swap out all the destinations with the right one as i get rendered html before writing it back as ajax response.
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.