How to retrieve an array in TWIG template?

Gusf89

New Member
Currently, I am using TWIG to display all my information(articles and comments). So, I first retrieve the articles and comments from my database and pass it into an array. This is then passed into my twig template. Then, I load each article and underneath each article I load in the comments of that article. These comments and the buttons associated with it(aka the new comment button) are all made in my macro. The macro just gets the array that contains the comments that I need to display. It display the comments for the article and with each comment it makes a reply button, so the user can reply to any comment or start a new thread. I have used AJAX and jQuery to store the new comments in my database without refreshing the page. However, I need to figure out a way to display the new comment without refreshing the whole page. Does anyone have any idea on how to do this in TWIG?The problem I am facing with TWIG right now is how to post comments asynchronously. I load the array of the current database of comments initially when I load the page. However, if my database updates, how do I update my array with it. Any suggestions? I was thinking of grabbing my array whenever a new comment is added, which is why my question is "How to retrieve an array in TWIG template?", but I am open to other suggestions.
 
Back
Top