I'm trying to use the extension RelatedContentByTags, but the entry on bolt_taxonomy column it's being recognized as column.
I have this error when I put {{ relatedcontentbytags(record) }}
on index.
'Twig_Error_Runtime thrown with message
"An exception has been thrown during the rendering of a template
("An exception occurred while executing ' SELECT bolt_entries.id FROM bolt_entries LEFT JOIN
bolt_taxonomy ON bolt_entries.id = bolt_taxonomy.content_id WHERE
bolt_entries.status = "published"AND bolt_entries.id != 3 AND
bolt_taxonomy.contenttype = "entries" AND (bolt_taxonomy.taxonomytype = "tags" AND
(bolt_taxonomy.slug = "teste2"))':
SQLSTATE[42703]: Undefined column: 7 ERROR: column "published" does not exist
LINE 1: ...t_taxonomy.content_id WHERE bolt_entries.status = "published...^") in "entry.twig" at line 65."
And the extension.php is that:
$results = array();
foreach ($tables as $name) {
$table = sprintf('%s%s', $tablePrefix, $name);
$querySelect = '';
$querySelect .= sprintf(' SELECT %s.id FROM %s', $table, $table);
$querySelect .= sprintf(' LEFT JOIN %s', $taxonomyTable);
$querySelect .= sprintf(' ON %s.id = %s.content_id', $table, $taxonomyTable);
$querySelect .= sprintf(' WHERE %s.status = "published"', $table);
if ($name == $record->contenttype['slug']) {
$querySelect .= sprintf('AND %s.id != '. $record->id, $table);
}
$querySelect .= sprintf(' AND %s.contenttype = "%s"', $taxonomyTable, $name);
$querySelect .= sprintf(' AND (%s)', $queryWhere);
$queryResults = $app['db']->fetchAll( $querySelect );
if (!empty($queryResults)) {
$ids = implode(' || ', \utilphp\util::array_pluck($queryResults, 'id'));
$contents = $app['storage']->getContent($name, array('id' => $ids, 'returnsingle' => false));
$results = array_merge( $results, $contents );
}
}
答案 0 :(得分:1)
根据您使用的数据库(我根据错误代码猜测Postgresql),用双引号""
括起来的文本可用于表示表名;单引号''
通常用于表示字符文字,因此请尝试将"published"
更改为'published'
(同样适用于条目,标记,和 teste2 当然也是如此)。