Version: 3.5.14 Reporter: Brian Litzinger —
This is an archived bug report. If you are experiencing a similar issue, upgrade to the latest release and if that does not solve the problem, submit a new bug report
I found a bug where the no_results conditional pair would not return its contents when parsing the template. I have a scenario where channel:entries finds a single entry, then the channel_entries_query_result hook is called, which then returns no results b/c its filtering the queries. When this happens, the no_results tag does not work. Fix is below. I also checked out EE4’s code and it appears to be doing the same thing.
public function no_results()
{
if ( ! preg_match("/".LD."redirect\s*=\s*(\042|\047)([^\\1]*?)\\1".RD."/si", $this->no_results, $match))
{
$this->log_item("Returning No Results Content");
return $this->no_results;
The channel->entries() method calls $this->parse_channel_entries() on line 297 (ee3), and parse_channel_entries() calls the channel_entries_query_result hook, and if that the $query_result is empty, it then sets $this->return_data = ee()->TMPL->no_results();
public function parse_channel_entries($per_row_callback = NULL)
{
// For our hook to work, we need to grab the result array
$query_result = $this->query->result_array();
// Ditch everything else
$this->query->free_result();
unset($this->query);
// -------------------------------------------
// 'channel_entries_query_result' hook.
// - Take the whole query result array, do what you wish
// - added 1.6.7
//
if (ee()->extensions->active_hook('channel_entries_query_result') === TRUE)
{
$query_result = ee()->extensions->call('channel_entries_query_result', $this, $query_result);
if (ee()->extensions->end_script === TRUE) return ee()->TMPL->tagdata;
}
//
// -------------------------------------------
if (empty($query_result))
{
return ee()->TMPL->no_results();
}
But since parse_channel_entries() is returning, its not doing anything that value returned:
// Calling the function, but not doing anything with the return value.
$this->parse_channel_entries();
$this->track_views();
if ($this->enable['pagination'] == TRUE)
{
$this->return_data = $this->pagination->render($this->return_data);
}
return $this->return_data;
The fix is to set $this->return_data = ee()->TMPL->no_results(), then return:
public function parse_channel_entries($per_row_callback = NULL)
{
// For our hook to work, we need to grab the result array
$query_result = $this->query->result_array();
// Ditch everything else
$this->query->free_result();
unset($this->query);
// -------------------------------------------
// 'channel_entries_query_result' hook.
// - Take the whole query result array, do what you wish
// - added 1.6.7
//
if (ee()->extensions->active_hook('channel_entries_query_result') === TRUE)
{
$query_result = ee()->extensions->call('channel_entries_query_result', $this, $query_result);
if (ee()->extensions->end_script === TRUE) return ee()->TMPL->tagdata;
}
//
// -------------------------------------------
if (empty($query_result))
{
$this->return_data = ee()->TMPL->no_results();
return;
}
ExpressionEngine implements Markdown Extra and BBCode. Please see the Markdown Extra docs and the BBCode Wikipedia article for a full reference.
**bold**
, __bold__
, *italics*
, _italics_
, ~strike/del~
, `code()`
bold, italics, strike/del, code()
Link: [link title](https://example.com)
Image: ![alt text](https://example.com/image.jpg)
[blockquote]...[/blockquote]
, [quote]...[/quote]
, and Markdown style:
> Some quoted text. > > This is all one quote.
[code]...[/code]
, and you can also specify the language for syntax highlighting, [code=php]...[/code]
GitHub flavored Markdown code fences are also supported:
``` public function decoderRing($str) { return str_rot13($str); } ```