Keyword

Stop the http:// being added to the URL in the User Profile

  • Simon Olsen
  • Simon Olsen's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 3 months ago #97126 by Simon Olsen
I'm a longtime advocate for using K2.

I'm currently doing some specific customisations and I want to use the URL field for something else.

Please note that I'm already using Extended User Info (great addition, I highly recommend it).

I've managed to stop the URL field from becoming a link.

In components/com_k2/templates/user.php, I've edited line 133 from

<?php echo JText::_("Website URL"); ?>: <a href="<?php echo $this->user->profile->url; ?>" target="_blank" rel="nofollow"><?php echo $this->user->profile->url; ?></a>

to

<?php echo JText::_("Website URL"); ?>: <?php echo $this->user->profile->url; ?>

Essentially removing the hyperlinking <a> tag.



However the K2 backend still adds http:// to the front of the URL field.

I've gone into administrator/components/com_k2/views/user/tmpl/default.php to see if I can comment out something that adds the http:// to the url after you save/apply the User record, but I can't see how it adds the http:// to the URL field.

Can someone point me in the right direction?

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

More
13 years 3 months ago #97127 by Simon Wells
Hi Simon,

 

Taking a look at this.

First thing i mention, try not to edit the k2 template in the component.

Why?

Update K2 and loose all your customisations.

Opt for a template over ride, take a look at the docs at simon.getk2.org or shout me.

 

This is going to need a bit more digging, but i suspect thats being created by the url function.

The "Website URL" is listed in the language file, but it does not create the http://

 

Let me ask the team a direct question.

 

SimonK2 Support 

 

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

  • Simon Olsen
  • Simon Olsen's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 3 months ago #97128 by Simon Olsen
I'm using a Gavick template that has a template override for k2 and other components. Very handy, as I tend to hack the code a fair bit, but still want the flexibility to update.

 

Have we come across how to stop the hyperlink happening?

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

  • Simon Olsen
  • Simon Olsen's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 3 months ago #97129 by Simon Olsen
I managed to get a hold of a developer friend of mine. Thanks for your help, Rui!So first, we'll need to change the Label of the Field both on the front end and back end from URL, Website URL and Website to whatever you want to make it. eg. 'Sport'My language is English Great Britain, or en-GB, so you'll need to find the relevant language for your site.In the file administrator/language/en-GB/en-GB.com_k2.ini there is no reference to URL, so I added the line after 571 which was USER IMAGE (AVATAR)=User image (avatar)I added a line break and added URL=SportThis updates the URL field label in the K2 backend.Next we do the front end. Go to language/en-GB/en-GB.com_k2.iniChange lines 105, 106 and 107 fromWEBSITE URL=Website URLWEBSITE URL=Website URLWEBSITE:=Website:toWEBSITE URL=SportWEBSITE URL=SportWEBSITE:=Sport:  &lt;-remember the colonNow to prevent the http:// being added to the fron the the URL in the K2 User backend.Edit the file administrator/components/com_k2/tables/k2user.php to comment out the check(). So change line 31-36 from    function check() {           if (trim($this-&gt;url) != '' &amp;&amp; substr($this-&gt;url, 0, 7) != 'http://')        $this-&gt;url = 'http://'.$this-&gt;url;        return true;    }to//    function check() {   //        if (trim($this->url) != '' && substr($this->url, 0, 7) != 'http://')//        $this->url = 'http://'.$this-&gt;url;//        return true;//    }Finally, to stop the field becoming a hyperlink on the K2 User on the frontend.Whether you have a template override and have separate com_k2 files or you want to hack the component/com_k2 files (remember what Simon Wells (K2 Support) said; when K2 updates a lot of these changes will be lost) you'll need to locate the file com_k2/templates/default/item.php in components/ or in your template files templates/$templatename/html/com_k2...Find the line:<a href="/<?php echo $this->item->author->profile->url; ?>" target="_blank" rel="nofollow"><?php echo str_replace('http://','',$this-&gt;item-&gt;author-&gt;profile-&gt;url); ?></a>and replace with<!-- <a href="/<?php echo $this->item->author->profile->url; ?>" target="_blank" rel="nofollow"><?php echo str_replace('http://','',$this-&gt;item-&gt;author-&gt;profile-&gt;url); ?></a>-->If you've done this correctly, then the Author block below K2 Items and on Author pages should feature your new field label (Sport), and whatever you populate the former-URL field in the K2 User profile (Football, Cricket, Swimming etc) and it won't be hyperlinked of have http:// at the front.

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


Powered by Kunena Forum