Welcome Guest [Log In] [Register]
We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Custom Text, Shortened Link Profile Field
Topic Started: Oct 9 2008, 11:38 PM (873 Views)
Fission
Member Avatar
SRS BSNS
[ *  *  *  *  * ]
Another version of the custom profile field (and my first JQuery code). I started out with the custom profile field tutorial in the ZB Docs and ended up with this. It shortens the URL in the middle if over a given length and allows for a custom URL text given by each member (optional) and has an editable divider character and is made to only work with profile fields of the given names.

Preview

The contents of the profile field is

Code:
 

http://www.google.com/search?rlz=1B3GGGL_enUS276US276&hl=en&q=omg+i+like+testing&btnG=Google+Search&aq=f&oq=,omg i see


Goes in Javascripts.

The Code
 

<!-- Custom Text, Shortened Link Profile Field by Fission (takariwtf@gmail.com) -->
<script type="text/javascript">
//<![CDATA[
function link_profilefield(where,div,len){
$("dl.user_profile dt:contains('" + where + "') + dd:contains('http://')").each(function () {
var item = $(this).html();
var b = item;
if (b.length > len) {b = b.slice(0,len/2) + '...' + b.slice(b.length - len/2, b.length)}
var url = item
if (item.search(div) > 0) {
url = item.slice(0,item.search(div))
b = item.slice(item.search(div)+1,item.length)
}
$(this).html('<a href="' + url + '">' + b + '</a>');
});}
$(function(){
link_profilefield("Link",",",30);
})
//]]>
</script>



Profile field - The name of the custom profile field.

Divider character - The character used to divide the URL from the custom text.

Maximum link length - If custom text isn't given, shorten the URL to this length.

Profile fields - Make news lines of this for multiple profile fields for linkage.

Before using this code, you need to make a new custom profile field (in your ZB ACP) of the type "1 text line".

I suggest asking your members to use TinyURL links instead of the full links to save space.
Edited by Fission, Oct 17 2008, 03:33 PM.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Code & Modification Database · Next Topic »
Add Reply