xiaohutai/bolt-relatedcontentbytags

The entry in bolt_taxonomy it's being recognized as column.

Closed this issue · 5 comments

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."

What database were you using? PostgreSQL?

Yep, PostgreSQL. I solved with the my pull request on this project. But I still don't get the related entries by tag. It only appears "Array" in the HTML displayed in the browser.

Are you using a for-loop in your template? Like so:

{% for item in relatedcontentbytags(record) %}
    <a href="{{ item.link }}">{{ item.title }}</a>
{% endfor %}

Sorry, my bad. In entry.twig ti's work fine, but index.twig don't. I'm pulling something wrong before the relatedcontentbytags...

If it's in index.twig, then it might be some settings in your app/config/config.yml:

homepage: page/1
homepage_template: index.twig

In this case, the record variable in index.twig will be the page with id = 1, if it's available and status = published.

If you're unsure whether the record exists, you can always do an additional check in Twig:

{% if record is defined %}
   ...
{% endif %}

Hope this helps.