er314 Posted August 10, 2012 Share Posted August 10, 2012 Hello, I have a Comments field in "an-article" template. Regarding structure, several "an-article" pages can be children of one same parent "a-container" page. Regarding display, one "an-article" page can be displayed simply on its own, or multiple "an-article" pages are displayed in sequence when invoking the display of the parent "a-container" page For displaying/rendering the Comments field, I simply invoke the "an-article" $page->comments->render(); and $page->comments->renderForm(); In terms of display, this is working fine : displaying the multiple "an-article" instances view shows the right comments for each instance displayed. However, in terms of posting a new comment, - it works fine if posted from a single "an-article" display, - but when posted from a multiple "an-article" display, actually the new comment is assigned simultaneously to all the instances that are currently displayed, instead of only to the one on which the post is performed. Any ideas how to solve this ? (ok, 1st workaround is to forbid posting new comment from the "multiple instance" view thanks Link to comment Share on other sites More sharing options...
WillyC Posted August 10, 2012 Share Posted August 10, 2012 u can makke post-comment.php tamplate and than tell renderForm to have.action there (see options] with page id as get var or urlsegment. That tamplate load page id from that get var or urlsegment. that tamplate can call renderForm from page u loaded to process it. nice too.bcoz all yur other pages can use.cache if u like too 1 Link to comment Share on other sites More sharing options...
ryan Posted August 10, 2012 Share Posted August 10, 2012 Here's more detail on the options WillyC mentioned: http://processwire.com/api/fieldtypes/comments/ For example, to set a new action attribute for renderForm so that it posts to a page called /post-comment/, you'd do this: $options = array('attrs' => array('action' => '/post-comment/?id=' . $page->id)); echo $page->renderForm($options); Then your post-comment template could do something like this: $id = (int) $input->get->id; if(!$id) throw new Wire404Exception(); $p = $pages->get((int) $input->get->id); if($p->id && $p->viewable() && $p->comments && count($input->post)) { // process comments echo $p->renderForm(); } else { throw new Wire404Exception(); } Link to comment Share on other sites More sharing options...
er314 Posted August 12, 2012 Author Share Posted August 12, 2012 thanks a lot for your help 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