|
uCoz Community » uCoz Modules » Forum » Thanks button with conditional operators (How to get User ID form Profile Url) |
Thanks button with conditional operators |
Hi!
I'm trying to make a Thanks button. I know how to make it in the forum. That is easy, but how to make it work outside of the forum? I found the code that calls the ReutationDo window : Code <a class="reputationDo" title="Thanks" href="javascript://" rel="nofollow" onclick="new _uWnd('Rd',' ',380,200,{autosize:1,closeonesc:1},{url:'/index/',type:'post',data:{a:'23',n:'1',c:'something'}});return false;"> <img src="/designimages/thanksbutton.gif"> </a> I have to edit this code by giving the UserID for the 'n' parameter.
Code <?substr( $PROFILE_URL$, strpos($PROFILE_URL$,'-'), 4 )?> Unfortunatelly it doesn't work because the lenght of that string (the IserID) is not allways 4 charachters. So my question is: How can I substract the UserID form the ProfileUrl? (Or is there an easyer way to make a thanx button outside the forum modul?) Thanks in advance for all your help Post edited by Cartman - Saturday, 2011-04-30, 5:29 PM
|
Cartman, the following thread may help as it explains a way of creating a thanks button using the reputation feature in the forum - http://forum.ucoz.com/forum/26-2161-8571-16-1222081614
|
Add this to your code. I'm not 100% sure it will work because I haven't tested it, but it's worth a try.
Code <?substr($PROFILE_URL$, strpos($PROFILE_URL$,'-'), len($PROFILE_URL$)?> To put it simple the substring takes an integer as the last parameter and the len() function gets the length of the profile url. In the middle parameter you have the position of the "-" so anything after that is what you're getting. That method you're using for a thanks button in my opinion is better. By the way, I see no relevant information on how to create a thanks button outside of the forum module in that link, CreativeCollusions. Post edited by kostova - Sunday, 2011-05-01, 1:50 AM
|
Quote (CreativeCollusions) Cartman, the following thread may help as it explains a way of creating a thanks button using the reputation feature in the forum - http://forum.ucoz.com/forum/26-2161-8571-16-1222081614 Thanks, but it doesn't help. I need the thanks button outside of the forum module.
Quote (kostova) Add this to your code. I'm not 100% sure it will work because I haven't tested it, but it's worth a try. Code <?substr($PROFILE_URL$, strpos($PROFILE_URL$,'-'), len($PROFILE_URL$)?> To put it simple the substring takes an integer as the last parameter and the len() function gets the length of the profile url. In the middle parameter you have the position of the "-" so anything after that is what you're getting. That method you're using for a thanks button in my opinion is better. Thank you! I've tried it, but the problem is still the same. The length of the string that contains the UserID is allways changes. For example the first registred ures gets the number 1 for UserID, and the 1245th registred user gets the number 1245 and so on. In the example the first UserId's length is 1 charachter and the other is 4. So the main question is still that how can I get the UserID in the following modules: I know that I can make a link to the user's profile page where there is the possibility to give reputation, but that is not too elegant. I would like to make it as simple as it can be. Post edited by Cartman - Sunday, 2011-05-01, 5:56 PM
|
No the problem isn't with my code. The problem is the string position functions aren't reading the $PROFILE_URL$ nor do they read $PERSONAL_PAGE_LINK$.
At least in my case. Do a test yourself and see if you get the same result: Code <?strpos($PROFILE_URL$,"-")?><br/> <?strpos($PROFILE_URL$,"8")?><br/> <?strpos($PROFILE_URL$,"your_site_name")?> That should return -1 which is not good. Aside from that, try counting manually the length of your url up to the dash and then try this code And please do tell me the result of your testing, will be much appreciated because I want to see if I'm the only one getting that error. Post edited by kostova - Tuesday, 2011-05-03, 1:52 AM
|
| |||
| |||