NorbertH Posted December 17, 2018 Share Posted December 17, 2018 I have an order form where the customer service selects the customer and then fills out the order form. Its almost like a very simple webshop. When you select the customer you get the order history and the form to place new orders all generated dynamically on one page. Now i am looking for a way to store comments about those users and their transactions and thought about using the comments module for this. The problem is that the page always uses the same page id as the content is generated dynamically, so the comments field always displays all comments for all customers. So my question is if there is a way to seperate the customers in the field call from whithin the template, for example by giving it a fake page id or maybe linking it to the page id of the user and not to the actual page calling it. Maybe like this : <?php echo $page->comments->render(array('page_id' => $page_id); ?> <?php echo $page->comments->renderForm(array('page_id' => $page_id); ?> Thanks in advance ! Link to comment Share on other sites More sharing options...
Robin S Posted December 18, 2018 Share Posted December 18, 2018 You can render the comments list and comment form for another page by calling render() and renderForm() on the value of the comments field of that other page. For example: // Get the page $p = $pages(1234); // Render comments list echo $p->comments->render(); // Render comment form echo $p->comments->renderForm(); If you have the "Redirect after comment post?" option checked then the user will be redirected to the page being commented on after the form is submitted. You probably don't want that so you could adjust the value of the hidden page_id field in the comment form. Unfortunately there's not much that's hookable in the FieldtypeComments module so you'd have to do this by editing CommentForm.php (first copy the FieldtypeComments module to /site/modules/) or use Javascript to change the field value. Alternatively you could disable the built-in redirect option and handle redirection after form submission via your own code. 4 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now