An 'embed' display has an option 'linked display'. This controls the path that the View uses for the exposed filters form.
The options for this let you set a custom URL.
However, I don't see how this can possibly work. In views_plugin_display we have this code:
/**
* Return the base path to use for this display.
*
* This can be overridden for displays that do strange things
* with the path.
*/
function get_path() {
if ($this->has_path()) {
return $this->get_option('path');
}
$display_id = $this->get_link_display();
if ($display_id && !empty($this->view->display[$display_id]) && is_object($this->view->display[$display_id]->handler)) {
return $this->view->display[$display_id]->handler->get_path();
}
// We need to get here for the custom URL option to have worked.
if ($this->get_option('link_display') == 'custom_url' && $link_url = $this->get_option('link_url')) {
return $link_url;
}
}
The above makes sense in itself. However, before we get to the point where we can see that the option is set to 'custom_url', we call get_link_display().
function get_link_display() {
$display_id = $this->get_option('link_display');
// If unknown, pick the first one.
if (empty($display_id) || empty($this->view->display[$display_id])) {
foreach ($this->view->display as $display_id => $display) {
if (!empty($display->handler) && $display->handler->has_path()) {
return $display_id;
}
}
}
else {
return $display_id;
}
// fall-through returns NULL
}
This will retrieve the 'link_display' option and find it's equal to 'custom_url'.
That is going to be an unknown display on the view, so empty($this->view->display[$display_id] is TRUE.
Therefore, the function will try to find another display on the view which has a path.
If it finds one, it returns the ID for that.
So now we get back to get_path(). Our call just got us a display_id, AND the way it was obtained is guaranteed to be a valid display ID!
if ($display_id && !empty($this->view->display[$display_id]) && is_object($this->view->display[$display_id]->handler)) {
return $this->view->display[$display_id]->handler->get_path();
}
So the condition here is guaranteed to pass. We return the path from the display ID which get_link_display() found.
It's impossible for this code at the end to be executed:
if ($this->get_option('link_display') == 'custom_url' && $link_url = $this->get_option('link_url')) {
return $link_url;
}
Comments
Comment #1
joachim CreditAttribution: joachim commentedVery simple fix: handle the special case first.
Comment #2
joachim CreditAttribution: joachim commentedOops.
Comment #4
joelpittetHmm this seems to make sense, bumping to get a few more eyeballs.
Comment #5
jwineichen CreditAttribution: jwineichen commented#2 worked for me
Comment #6
jwineichen CreditAttribution: jwineichen commentedWould be great if this could be reviewed and pushed the to next release.
Comment #7
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 5 year old patch in #2 to views_plugin_display.inc does not apply to the latest views 7.x-3.x-dev.
Comment #8
Andrew Answer CreditAttribution: Andrew Answer as a volunteer commentedPatch rerolled.
Comment #9
joelpittetI've been using the patch in #2 for a while now, seems like others agree.
Comment #11
DamienMcKennaCommitted. Thanks!