Keyword

How to strip tags in Module K2 comments

  • Suba
  • Suba's Avatar Topic Author
  • Visitor
11 years 4 months ago #113165 by Suba
I have created a latest comment module with Module K2 comments. Is there an option to prevent it from parsing html in the module? I don't want the links to be clickable in the module, all should appear as plain text.

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
11 years 4 months ago #113166 by Yiota
You could make a template override for the module and comment out the link part.

Please Log in or Create an account to join the conversation.

  • Suba
  • Suba's Avatar Topic Author
  • Visitor
11 years 4 months ago #113167 by Suba

Yiota Ziaggou wrote: You could make a template override for the module and comment out the link part.

What should I edit?
I tried to add strip_tags() to $comment->commenText, but that didn't work.

<?php if($params->get('commentLink')): ?>
                        <a href="<?php echo $comment->link; ?>"><span class="lcComment"><?php echo $comment->commentText; ?></span></a>
                        <?php else: ?>
                        <span class="lcComment"><?php echo $comment->commentText; ?></span>
                        <?php endif; ?>

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 4 months ago #113168 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How to strip tags in Module K2 comments
Did you strip tags for both instances?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Suba
  • Suba's Avatar Topic Author
  • Visitor
11 years 4 months ago #113169 by Suba
Yes.
			<?php if($params->get('commentLink')): ?>
			<a href="<?php echo $comment->link; ?>"><span class="lcComment"><?php echo strip_tags($comment->commentText); ?></span></a>
			<?php else: ?>
			<span class="lcComment"><?php echo strip_tags($comment->commentText); ?></span>
			<?php endif; ?>

I have confirmed that the template overriding is working by putting some string inside <span class="lsComment"></span>

Please Log in or Create an account to join the conversation.

  • Suba
  • Suba's Avatar Topic Author
  • Visitor
11 years 4 months ago #113170 by Suba
Bump

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 4 months ago #113171 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How to strip tags in Module K2 comments
strip_tags() Will kill all of your HTML code, if your comment has any HTML code which I think K2 is only allowing basic tags.

If you want to remove allthe links you have to remove all the <a> elements eg. you have to remove this completely

<a href="<?php echo $comment->link; ?>"><span class="lcComment"><?php echo $comment->commentText; ?></span></a>
<?php else: ?>

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum