Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-05-17 22:11:51

christina.helen
Member
From: California
Registered: 2009-03-20
Posts: 38

Style author comments

Hi, I’m trying to style my comments that are currently using the zem_nth plug-in in my Comments form to alternate colors. Now, I’d like an individual style for my comments and have the sed_comment_pack plug-in but not sure how to make it work with the following (from Comments form):

<div class="comments">
 <dl class="comment_list">
 <dt><txp:comment_permlink><txp:sed_comment_number /></txp:comment_permlink></dt>
	<txp:zem_nth step="1" of="2"><dd class="odd_name"><txp:comment_name /></dd></txp:zem_nth>
        <txp:zem_nth step="2" of="2"><dd class="even_name"><txp:comment_name /></dd></txp:zem_nth>
        <txp:zem_nth step="1" of="2"><dd class="odd_time"><txp:comment_time /></dd></txp:zem_nth>
        <txp:zem_nth step="2" of="2"><dd class="even_time"><txp:comment_time /></dd></txp:zem_nth>
        <txp:zem_nth step="1" of="2"><dd class="odd_comment"><txp:comment_message /></dd></txp:zem_nth>
        <txp:zem_nth step="2" of="2"><dd class="event_comment"><txp:comment_message /></dd></txp:zem_nth>
  </dl>
</div>

I have my author comments styled using the classes author_name, author_time, and author_message. It seems that I probably could do everything (alternate colors, style author comments) with the sed_comment_pack plug-in but I don’t want to mess up what I’ve currently got. What would be the best way for me to go about this? (And thanks!)

Last edited by christina.helen (2009-05-19 03:00:24)

Offline

#2 2009-05-19 17:33:42

christina.helen
Member
From: California
Registered: 2009-03-20
Posts: 38

Re: Style author comments

Thank you for your suggestion. I am trying to figure out how to style my own comments using the sed_comment_pack plug-in with the code I have above for my comments. I haven’t been successful yet.

Offline

#3 2009-05-19 18:08:48

JanDW
Plugin Author
From: Providence, RI, USA
Registered: 2008-07-18
Posts: 327
Website

Re: Style author comments

without extra plugin: you could use insert <txp:comment_name /> into a <txp:variable /> and then add a class by checking <txp:if_variable>

So something like:

<txp:variable name="if_comment_name" value='<txp:comment_name />' />
<dd class="<txp:if_variable name="if_comment_name" value="Christina Helen">author_name
          <txp:else />odd_name</txp:if_variable>">...</dd>

edit. This will only work from Textpattern 4.0.7 and upwards.

Last edited by JanDW (2009-05-19 18:11:09)


TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX

Offline

#4 2009-05-19 18:13:29

christina.helen
Member
From: California
Registered: 2009-03-20
Posts: 38

Re: Style author comments

Thank you, Jan, I will try this out.

Offline

#5 2009-05-19 19:31:18

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Style author comments

JanDW wrote:

without extra plugin: you could use insert <txp:comment_name /> into a <txp:variable /> and then add a class by checking <txp:if_variable>

You don’t need that. sed_comment_pack adds a class to the surrounding div: commentator-name_of_commentator (where name_of_commentator is the name entered in the comment form). So you can style div.commentator-christina in your css.

Also you don’t need zem_nth, because sed_comment_pack can do it. Use the attributes odd_class and even_class in the <txp:sed_get_comment_class /> tag.

Offline

#6 2009-05-21 01:30:16

christina.helen
Member
From: California
Registered: 2009-03-20
Posts: 38

Re: Style author comments

Thank you for the help. I finally have the comments styled with alternating colors and unique styling for my own comments. Here is what my comments form looked like

<div class="<txp:sed_get_comment_class />">
 <dl>
 <dt><txp:comment_permlink><txp:sed_comment_number /></txp:comment_permlink></dt>
	<dd class="name"><txp:comment_name /></dd>
        <dd class="time"><txp:comment_time /></dd>
        <dd class="comment"><txp:comment_message /></dd>
  </dl>
</div>

The classes were styled using div.odd, div.even, div. author. Thanks, Els, for steering me to a solution. Oh, when using .author class be sure to use your txp Real Name and email address found in Admin > Users when writing your comment.

Last edited by christina.helen (2009-05-22 03:11:04)

Offline

Board footer

Powered by FluxBB