Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Resources
  • Code Requests
  • Completed Requests
  • [Completed] [ZB] Custom profile fields in signature
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
[Completed] [ZB] Custom profile fields in signature; Within a custom spoiler tag
Tweet Topic Started: Oct 16 2009, 02:05 AM (301 Views)
thebawp Oct 16 2009, 02:05 AM Post #1


Posts:
100
Group:
Member
Member
#2,904
Joined:
May 2, 2009
Hi, I found this code here:

http://zbcode.com/topic/2292296/1/#new

Code:
 
<script type="text/javascript">
//User Profile in Sig Code
$(".c_sig").each(function(){
$(this).parent().prev().find(".user_profile").appendTo($(this))
})
</script>


by Dorith. It's very nice, works well, and is a bit similar to what I'm after.

I'm wondering if it's possible to have certain lines in the user_profile (but not all) added to the signature - for arguments sake, let's say the profile field is called 'Roleplay Characters'. The profile field could contain just a name, i.e. 'Sam' or it could have a link to an image 'http://imageplace.net/image.jpg' that I would want to show as an image.

Finally, I would want this to be placed in a spoiler tag, but one that doesn't say spoiler but 'More info' or something along those lines.

Also, I've noticed on the above code that when the profile shows up in the signature, the profile field name is to the left of the screen but the info is bang in the middle, I'd want this to be either all to the left or all in the centre.

Here's an example of Dortih's code.

If I've not made myself clear or need to elaborate with mock ups or anything, please let me know.

Thanks.
Offline Profile Goto Top
 
RedBldSandman Oct 16 2009, 05:54 PM Post #2
Member Avatar
ZIPPY!

Posts:
482
Group:
Coding Staff
Member
#2,122
Joined:
Jan 25, 2009
I've made a code, hopefully its what you wanted but if not, just ask for any changes :D
Code:
 
var arr_up = [];
n=0
//Begin Editing

var arr_sep = " "
arr_up[n++] = ["Roleplay Characters","text"]
arr_up[n++] = ["Roleplay Image","image"]

// Stop editing
var arr_upl = arr_up.length
if (location.href.match("/topic")) {
$(".user_profile").each(function() {
var arr_test = 0
$(this).find("dt").each(function() {
for (i=0;i<arr_upl;i++) {
if ($(this).text()==arr_up[i][0]) {
if (arr_test!=1) {
arr_test = 1
$(this).parent().parent().parent().next().children().attr("class","c_sig").append("<br /><div class='spoiler_toggle'>More info</div><div style='display: none;' class='spoiler'></div>")
}
var arr_ap = (arr_up[i][1].toLowerCase()=="image")?"<div class='arr_d' >" + $(this).html() + arr_sep + "<img src='"+$(this).next().text()+"' /></div>":"<div class='arr_d' >" + $(this).html() + arr_sep + $(this).next().html() + "</div>"
$(this).parent().parent().parent().next().children().children(".spoiler_toggle:contains(More info)").next().append(arr_ap)
$(this).hide().next().hide()
}
}
})
if (!$(this).find("dt").is(":visible")) {
$(this).hide()
}
})
}
else if (location.href.match("/profile")) {
var arr_test = 0
$(".user_profile dt").each(function() {
for (i=0;i<arr_upl;i++) {
if ($(this).text()==arr_up[i][0]) {
if (arr_test!=1) {
arr_test = 1
$(this).parent().parent().next().attr("class","c_sig").append("<br /><div class='spoiler_toggle'>More info</div><div style='display: none;' class='spoiler'></div>")
}
var arr_ap = (arr_up[i][1].toLowerCase()=="image")?"<div class='arr_d' >" + $(this).html() + arr_sep + "<img src='"+$(this).next().text()+"' /></div>":"<div class='arr_d' >" + $(this).html() + arr_sep + $(this).next().html() + "</div>"
$(this).parent().parent().next().children(".spoiler_toggle:contains(More info)").next().append(arr_ap)
$(this).hide().next().hide()
}
}
})
if (!$(".user_profile dt").is(":visible")) {
$(".user_profile").hide()
}

}
So, just to explain. There are 2 things to edit. The first is the seperator between the Field Name and the Entry which is the part called arr_sep
Code:
 
var arr_sep = ":"
This would put a colon in between the Field Name and the Entry.

The second thing to edit is the list of Profile Fields which you'd like to grab and their type.
Code:
 
arr_up[n++] = ["EXACT PROFILE FIELD NAME","TYPE"]
Add as many of that line as you wish, corresponding to the Profile Field Name and the type. The type can either be "text" or "image". ONLY one of those 2. "text" will just grab the text and put it in like normal but "image" will take the entry and make it the source of an img tag (so you can put a url to an image in there).

Just place the code "Below the Board". Hopefully I've explained that well enough and its what you wanted xD

EDIT: Just updated the code so that it works on the Profile page as well (forgot about that one xD )

EDIT 2: Removed the single quote I'd accidently left in the code xD
Edited by RedBldSandman, Oct 17 2009, 07:44 PM.
Posted Image
"To iterate is human, to recurse divine."

Offline Profile Goto Top
 
thebawp Oct 17 2009, 04:27 PM Post #3


Posts:
100
Group:
Member
Member
#2,904
Joined:
May 2, 2009
Hey, thanks.

I've added this below my board and added the javascript tags like this

Code:
 

<script type="text/javascript">
var arr_up = [];
n=0
//Begin Editing

var arr_sep = " "
arr_up[n++] = ["'Roleplay Alias","text"]

// Stop editing
var arr_upl = arr_up.length
if (location.href.match("/topic")) {
$(".user_profile").each(function() {
var arr_test = 0
$(this).find("dt").each(function() {
for (i=0;i<arr_upl;i++) {
if ($(this).text()==arr_up[i][0]) {
if (arr_test!=1) {
arr_test = 1
$(this).parent().parent().parent().next().children().attr("class","c_sig").append("<br /><div class='spoiler_toggle'>More info</div><div style='display: none;' class='spoiler'></div>")
}
var arr_ap = (arr_up[i][1].toLowerCase()=="image")?"<div class='arr_d' >" + $(this).html() + arr_sep + "<img src='"+$(this).next().text()+"' /></div>":"<div class='arr_d' >" + $(this).html() + arr_sep + $(this).next().html() + "</div>"
$(this).parent().parent().parent().next().children().children(".spoiler_toggle:contains(More info)").next().append(arr_ap)
$(this).hide().next().hide()
}
}
})
if (!$(this).find("dt").is(":visible")) {
$(this).hide()
}
})
}
else if (location.href.match("/profile")) {
var arr_test = 0
$(".user_profile dt").each(function() {
for (i=0;i<arr_upl;i++) {
if ($(this).text()==arr_up[i][0]) {
if (arr_test!=1) {
arr_test = 1
$(this).parent().parent().next().attr("class","c_sig").append("<br /><div class='spoiler_toggle'>More info</div><div style='display: none;' class='spoiler'></div>")
}
var arr_ap = (arr_up[i][1].toLowerCase()=="image")?"<div class='arr_d' >" + $(this).html() + arr_sep + "<img src='"+$(this).next().text()+"' /></div>":"<div class='arr_d' >" + $(this).html() + arr_sep + $(this).next().html() + "</div>"
$(this).parent().parent().next().children(".spoiler_toggle:contains(More info)").next().append(arr_ap)
$(this).hide().next().hide()
}
}
})
if (!$(".user_profile dt").is(":visible")) {
$(".user_profile").hide()
}

}
</script>


But it doesn't seem to be working?

Board link: http://s1.zetaboards.com/North_Castle_Test/topic/2332819/1/#new

Thanks for helping with this, it's appreciated. =)
Offline Profile Goto Top
 
Choco Oct 17 2009, 05:08 PM Post #4
Member Avatar
¡ʎɹoʇɔɐɟ ʎʇıʌɐɹƃ ɐ uı pǝddɐɹʇ ɯ,ı 'dןǝɥ

Posts:
589
Group:
Admins
Member
#3,272
Joined:
Jun 30, 2009
Coding language
Everything
See this:

arr_up[n++] = ["'Roleplay Alias","text"]

Change it to this:

arr_up[n++] = ["Roleplay Alias","text"]

:)
Posted ImageIt's a magical world, Hobbes, ol'd buddy... ...let's go exploring!
In progress: Something Special ;)
Offline Profile Goto Top
 
RedBldSandman Oct 17 2009, 07:43 PM Post #5
Member Avatar
ZIPPY!

Posts:
482
Group:
Coding Staff
Member
#2,122
Joined:
Jan 25, 2009
Oops, left in a single quote by accident xD Just change it to what Choco suggested and it should work fine :D
Posted Image
"To iterate is human, to recurse divine."

Offline Profile Goto Top
 
thebawp Oct 22 2009, 05:43 PM Post #6


Posts:
100
Group:
Member
Member
#2,904
Joined:
May 2, 2009
Yes, that was it, can't believe I missed it, especially after I checked! Thanks both, there are probably a few more things I'll want to do with this, but hopefully I can figure it out myself!

You can close this now, thank you!
Offline Profile Goto Top
 
RedBldSandman Oct 22 2009, 05:46 PM Post #7
Member Avatar
ZIPPY!

Posts:
482
Group:
Coding Staff
Member
#2,122
Joined:
Jan 25, 2009
If you need any changes, just say. Glad you liked it :)
Posted Image
"To iterate is human, to recurse divine."

Offline Profile Goto Top
 
Dorith Oct 22 2009, 05:54 PM Post #8
Member Avatar
Has just entered the Matrix

Posts:
2,069
Group:
Former Staff
Member
#1,854
Joined:
Dec 23, 2008
You're welcome.
See? We can read thoughts too. ;)

Your request has been completed, and we're moving it to the correct forum. We hope it works for you; if it doesn't, feel free to post another request topic in the requests forum. Just remember: read the rules first!

Thanks,
The ZBCode Staff
Posted Image
Posted Image
(Made emoticon using Codes Rock's Smiley Generator)
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Completed Requests · Next Topic »
Locked Topic

Track Topic · E-mail Topic Time: 2:27 PM Jul 11
Hosted for free by ZetaBoards · Privacy Policy