Keyword

How do I disable the url's of those who comment?

  • Tessa Priddy
  • Tessa Priddy's Avatar Topic Author
  • Offline
  • New Member
More
10 years 9 months ago #130400 by Tessa Priddy
I've looked through the backend of my website and I can't find a way to disable the url's of those who comment on my website. They may enter a url when they make comments and I really don't want those links to work. I read that it has to be done using code, but the article didn't make sense to me and I need specific instructions if it does require code. I don't want it to mess up when I update K2 or Joomla in the future. How do I disable the urls included with comments of guests and/or signed in users? The url's aren't part of the comments by the way. They are part of the information given when a guest or signed in user leaves a comment.

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

More
10 years 9 months ago #130401 by Lefteris
This requires some basic code. Actually you just need to remove a part of code, not write code. First read getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates to see how you can override the default output of K2. Then just edit the layout file item.php so the part :
			    <?php if(!empty($comment->userLink)): ?>
			    <a href="<?php echo JFilterOutput::cleanText($comment->userLink); ?>" title="<?php echo JFilterOutput::cleanText($comment->userName); ?>" target="_blank" rel="nofollow">
			    	<?php echo $comment->userName; ?>
			    </a>
			    <?php else: ?>
			    <?php echo $comment->userName; ?>
			    <?php endif; ?>
looks like:
<?php echo $comment->userName; ?>

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

  • Tessa Priddy
  • Tessa Priddy's Avatar Topic Author
  • Offline
  • New Member
More
10 years 9 months ago #130402 by Tessa Priddy
Replied by Tessa Priddy on topic Re: How do I disable the url's of those who comment?
I read the article you referenced, Lefteris. I saved a copy of the protostar-default template and named it "godlywriterproto-default" when I first began working on my new website. This copy is the template that I've been using as my default. Is it still necessary to do what is suggested in the article, since I saved this copy with a new name? I haven't done the second part of your suggestion yet, because I'm not sure if I should alter it without knowing the answer to this question regarding the K2 sub-templating. I'm having some difficulty understanding the concept. Since I created the copy template through the backend, is it still necessary to do the copy and paste process described in the article? Thanks for your suggestions and help!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 9 months ago #130403 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How do I disable the url's of those who comment?
Yes, you definitely have to override K2 (follow the post's instructions).
Otherwise you will lose your edits when you update K2.

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

  • Tessa Priddy
  • Tessa Priddy's Avatar Topic Author
  • Offline
  • New Member
More
10 years 9 months ago #130404 by Tessa Priddy
Replied by Tessa Priddy on topic Re: How do I disable the url's of those who comment?
Alright, the article said, "COPY THE CONTENTS of the folder /components/com_k2/templates/ and PASTE it into /templates/YOURJOOMLATEMPLATE/html/com_k2/" I went to do that, but my joomla template html file does not contain com_k2. I'm assuming that I need to create a file called com_k2, but my file manager requires that I save it with an extension. What should the com-k2 file extension be? There are a good many possibilities from CSS, text, html, scripts, and the extensions under those. Does it matter which one I save it as?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 9 months ago #130405 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How do I disable the url's of those who comment?
You need to create a folder not a file.

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

  • Tessa Priddy
  • Tessa Priddy's Avatar Topic Author
  • Offline
  • New Member
More
10 years 9 months ago - 10 years 9 months ago #130406 by Tessa Priddy
Replied by Tessa Priddy on topic Re: How do I disable the url's of those who comment?
I created the folder, completed the steps mentioned in the article, and have a k2 sub-template :woohoo: I followed Lefteris instructions for changing the code, then went to the backend of Joomla, and chose my sub-template that I created. It was right there on the drop-down list, which was great. However, the changes to the code (removing some) and leaving that one line did not have the desired affect.

The member's url's all link to their own page within my website, which is good. I want it to do that, but when the guest's give a url I don't want their name to link to their off site link. The reason is that I don't want my site to link to inappropriate or offensive websites. I don't want to have to check each one either. I don't want guest names to link to an outside website, but want to keep member names link to their onsite page. Thanks for the help so far, is there anything else you can tell me to resolve this?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 9 months ago #130407 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How do I disable the url's of those who comment?
Yes you can perform a simple check, if the user is registered display the original code else display the modified code.

The check whether uses is a guest or not is:
<?php if($user->guest): ?>
// altered code
<? php else: ?>
// Original code
<?php endif; ?>

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

  • Tessa Priddy
  • Tessa Priddy's Avatar Topic Author
  • Offline
  • New Member
More
10 years 9 months ago #130408 by Tessa Priddy
Replied by Tessa Priddy on topic Re: How do I disable the url's of those who comment?
Krikor, I did what you said and now when I go to the Bible study page this error shows up:

Parse error: syntax error, unexpected T_ELSE in study/templates/MYTEMPLATE/html/com_k2/biblestudy/item.php on line 622

Do you have any idea what I did wrong?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 9 months ago #130409 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How do I disable the url's of those who comment?
I accidentally pasted <? php else: ?> instead of <?php else: ?>

Can you check if you duplicated my error?

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

  • Tessa Priddy
  • Tessa Priddy's Avatar Topic Author
  • Offline
  • New Member
More
10 years 9 months ago #130410 by Tessa Priddy
Replied by Tessa Priddy on topic Re: How do I disable the url's of those who comment?
I did duplicate your error, but I changed it and got a new error message.
The error message: Parse error: syntax error, unexpected T_ELSE in ... /templates/MYTEMPLATE/html/com_k2/biblestudy/item.php on line 626

Here is the code that I added, because I already had made the previous changes mentioned in this thread. I copied and pasted the code provided in this thread. Here is the code I used (including the code you gave me plus some code preceding it to ensure I put it in the right place)

<span class="commentAuthorName">
<?php echo JText::_('K2_POSTED_BY'); ?>
<?php if(!empty($comment->userLink)): ?>
<?php if($user->guest): ?>
<?php echo $comment->userName; ?>

<?php else: ?>
<a href="<?php echo JFilterOutput::cleanText($comment->userLink); ?>" title="<?php echo JFilterOutput::cleanText($comment->userName); ?>" target="_blank" rel="nofollow">
<?php echo $comment->userName; ?>
</a>
<?php else: ?>
<?php echo $comment->userName; ?> <?php endif; ?>
</span>

Thanks!

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

More
10 years 9 months ago #130411 by Lefteris
This is probably the exact code you need:
<span class="commentAuthorName">
<?php echo JText::_('K2_POSTED_BY'); ?>
<?php if(!empty($comment->userLink)): ?>
<?php if($user->guest): ?>
<?php echo $comment->userName; ?>
<?php else: ?>
<a href="<?php echo JFilterOutput::cleanText($comment->userLink); ?>" title="<?php echo JFilterOutput::cleanText($comment->userName); ?>" target="_blank" rel="nofollow">
<?php echo $comment->userName; ?>
</a>
<?php endif; ?>
</span> 

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

  • Tessa Priddy
  • Tessa Priddy's Avatar Topic Author
  • Offline
  • New Member
More
10 years 9 months ago #130412 by Tessa Priddy
Replied by Tessa Priddy on topic Re: How do I disable the url's of those who comment?
I tried the copied and pasted the code. The result was a similar error message to the previous ones. I played around with it throughout the day and couldn't get it to work right :( Would it be easier to alter the form some how so that if a user is a guest, then the website url field in the form won't be available to enter a web address? OR do you have some other suggestion?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 9 months ago #130413 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How do I disable the url's of those who comment?
<?php echo JText::_('K2_POSTED_BY'); ?>
<?php if(!empty($comment->userLink)): ?>
<?php if($user->guest): ?>
<?php echo $comment->userName; ?>
<?php else: ?>
<a href="<?php echo JFilterOutput::cleanText($comment->userLink); ?>" title="<?php echo JFilterOutput::cleanText($comment->userName); ?>" target="_blank" rel="nofollow">
<?php echo $comment->userName; ?>
</a>
<?php endif; ?>
<?php endif; ?>

A trailing <?php endif; ?> was missing.

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

  • Tessa Priddy
  • Tessa Priddy's Avatar Topic Author
  • Offline
  • New Member
More
10 years 9 months ago #130414 by Tessa Priddy
Replied by Tessa Priddy on topic Re: How do I disable the url's of those who comment?
Good news, I added the trailing code and I didn't get the previous error messages anymore. Bad news, it still doesn't keep the user name of the guests from linking to their website. It doesn't seem to do anything different than the original code on the frontend either. Thanks for trying to help me with it! I can't seem to find anybody who knows a code on the internet to alter the code that will allow the user name for members to continue to link and at the same time keep guests user names from linking to an outside url.

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

More
10 years 4 months ago #135735 by Robert_ITMan
Replied by Robert_ITMan on topic How do I disable the url's of those who comment?
My solution to this issue was simple and the answer to mine will likely answer the problems above too. I wanted to disable the URL from the comment form - I like the user URL - and I have it so only registered users can comment - so I have no need for the comment form to ask for the 'Website URL'.. I just needed to know what file to edit in my template and this is what worked for me:

I edited this file:
templates/(my template)/html/com_k2/default/item_comments_form.php
=> as copied from components/com_k2/templates/default/item_comments_form.php
<?php /* hidden - don't want external links for comments
	<label class="formUrl" for="commentURL"><?php echo JText::_('K2_WEBSITE_URL'); ?></label>
	<input class="inputbox" type="text" name="commentURL" id="commentURL" value="<?php echo JText::_('K2_ENTER_YOUR_SITE_URL'); ?>"  onblur="if(this.value=='') this.value='<?php echo JText::_('K2_ENTER_YOUR_SITE_URL'); ?>';" onfocus="if(this.value=='<?php echo JText::_('K2_ENTER_YOUR_SITE_URL'); ?>') this.value='';" />
end hide - following added to have the URL field hidden in the form */ ?>
	<!-- hide the URL -->
    <input type="hidden" name="commentURL" id="commentURL" value="<?php echo JText::_('K2_ENTER_YOUR_SITE_URL'); ?>"  onblur="if(this.value=='') this.value='<?php echo JText::_('K2_ENTER_YOUR_SITE_URL'); ?>';" onfocus="if(this.value=='<?php echo JText::_('K2_ENTER_YOUR_SITE_URL'); ?>') this.value='';" />

www.ourfingertips.ca - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 4 months ago #135759 by Krikor Boghossian
Replied by Krikor Boghossian on topic How do I disable the url's of those who comment?
Yes, this is the correct procedure for overriding K2's templates.

More info can be found here getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

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


Powered by Kunena Forum