I am wondering if I can connect an array of comments to a collection much like articles has comments.
Topic summary
A user asks whether comments can be linked to a collection in the same way articles are associated with collections.
Proposed Solution:
- Use a tagging system with a specific prefix (e.g., βar:testβ) applied to both the collection and related articles
- Create an AJAX search template (with layout=none) that queries articles by tag and displays their comments using Liquid code
- Use JavaScript to call the AJAX search URL (e.g., /search?q=ar:test&type=article) and display results on the collection page
- Parse collection tags with the βar:β prefix to determine which articles to retrieve
Status:
The original poster plans to test this approach and report back. The discussion remains open pending implementation results.
Hi @ewelsh
You try add a tag to collection and the article. After that base on this tags to get all articles and all comments to show on collection. May it will have a little complex. I just suggest a solution here for you.
EX: Test collection β add tag (ar:test)
A article β add tag (ar:test)
B article β add tag (ar:test)
C article β add tag (ar:test)
-
In the collection page. Foreach tags if tag has a prefix = ar: after that get this tag
-
create a search ajax template with layout=none β base on results write liquid code to show comments here.
-
Use javascript to call ajax search page-> URL: /search?q=ar:test&type=article ( replace ar:test = tag thay you found in step 1)
-
Show result of ajax on collection page.
I will give this a go and report back, thank you!