Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How do I Remove the div 'comments-wrapper'?
I have been experimenting with customizing comments of late and run into a roadblock with <txp:comments_form />. Phil mentioned this issue in 2010 and Stef has a long list of ideas to do with the comments subsystem.
For anyone who hasn’t look in the issue, a quick explanation:
Normally, in order to generate a comments form, you will want to use:
<txp:comments_form />
Unless a specific form is specified, the Comments form comment_form is used. This is an example of the output you get when the form is left completely blank.
<form id="txpCommentInputForm" method="post" action="/2014/09/28/test-for-comments#cpreview">
<div class="comments-wrapper">
<input type="hidden" value="21" name="parentid" />
<input type="hidden" value="/2014/09/28/test-for-comments" name="backpage" />
</div>
</form>
In my case, the div seem to be interfering with what I am attempting to do. I know rah_replace and etc_query are out there (I also found Adding a class to the comments input form itself) but I am not quite sure if they would be the best solution in this case.
Offline
Re: How do I Remove the div 'comments-wrapper'?
I don’t actually have a non-hacky solution for removing the wrapping element, but suspect it would be a candidate for adding it only if the doctype pref was set to XHTML. For HTML5 we could safely omit the wrapper, thus giving you a get-out-of-div-free card.
As I say, doesn’t help you right now, but it’s one of those things we could fix fairly easily. If you’d like to try it out, hack publish/comments.php
as follows. Change line 150 from:
n.'<div class="comments-wrapper">'.n.n;
to:
($doctype === 'xhtml' ? n.'<div class="comments-wrapper">'.n.n : '');
and change line 226 from:
$out .= n.n.'</div>'.n.'</form>';
to:
$out .= n.n.($doctype === 'xhtml' ? '</div>' : '').n.'</form>';
That’s all I’d do in core.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: How do I Remove the div 'comments-wrapper'?
Bloke wrote #284380:
That’s all I’d do in core.
I had looked at that but I was looking for a non-hacky way. Which I found sort of – not the prettiest but it works.
<txp:rah_replace from='id="txpCommentInputForm",<div class="comments-wrapper">,' to='role="form" class="clearfix",<div>,'>
<txp:comments_form />
</txp:rah_replace>
I couldn’t remove the final closing div because it also removed all the other ones I actually needed. But this got me close enough.
<div class="well">
<h4>Comment</h4>
<form role="form" class="clearfix" method="post" action="/2014/09/28/test-for-comments#cpreview">
<div>
<div class="col-md-6 form-group">
<label class="sr-only" for="name">Name</label>
<input type="text" class="form-control" id="name" placeholder="Name">
</div>
<div class="col-md-6 form-group">
<label class="sr-only" for="email">Email</label>
<input type="email" class="form-control" id="email" placeholder="Email">
</div>
<div class="col-md-12 form-group">
<label class="sr-only" for="email">Comment</label>
<textarea class="form-control" id="comment" placeholder="Comment"></textarea>
</div>
<div class="col-md-12 form-group text-right">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
<input type="hidden" value="21" name="parentid" />
<input type="hidden" value="/2014/09/28/test-for-comments" name="backpage" />
</div>
</form>
</div>
I am trying to convert a Bootstrap Template to work with Textpattern and I still need to work on the form obviously but at least it displays correctly now.
Offline
Re: How do I Remove the div 'comments-wrapper'?
Hey Stef, do you want to add that into 4.6 core once git move has finished?
Offline
Re: How do I Remove the div 'comments-wrapper'?
philwareham wrote #284395:
Hey Stef, do you want to add that into 4.6 core once git move has finished?
Sure. I was going to put it in 4.5.x too.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: How do I Remove the div 'comments-wrapper'?
Cool. Thanks.
Offline
Re: How do I Remove the div 'comments-wrapper'?
Offline
Re: How do I Remove the div 'comments-wrapper'?
Yes it’s underway
Offline
Re: How do I Remove the div 'comments-wrapper'?
Offline
#10 2014-10-01 10:50:06
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,304
Re: How do I Remove the div 'comments-wrapper'?
michaelkpate wrote #284381:
I couldn’t remove the final closing div because it also removed all the other ones I actually needed.
Some solutions with rah_replace might look a little broken. Take e.g. that thing here with the line break inside the from
value:
<txp:rah_replace from='</div>
</form>' to='</form>'>
<txp:comments_form />
</txp:rah_replace>
It’s a little hard to read but gets you there.
You simply copy the necessary code spots from the browser source, incl. blanks, tabs, returns, and paste them into rah_replace. Avoid copying from JS generated/influenced code like from e.g. Firebug, those often change code.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline