• Page 1 of 1
  • 1
uCoz Community » uCoz Modules » Forum » Thanks button with conditional operators (How to get User ID form Profile Url)
Thanks button with conditional operators
Cartman
Posts: 31
Reputation: 2

Message # 1 | 5:28 PM
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 want a Thanks button under every comment and article.

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.
My problem is that there is no corresponding conditional operator for the UserID in the articles, blogs or comments moduls.
I would like to substract the UserID from the ProfileUrl with conditional operators.
I tried to do this with this code:

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 wink

Post edited by Cartman - Saturday, 2011-04-30, 5:29 PM
CodeResolution
Posts: 1570
Reputation: 58

Message # 2 | 11:23 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
Kind regards,
Elliott.

"The best uCoz" critic since 2007.
Qualified website, branding, print & user interface designer.

I'm on Behance and Twitter.
kostova
Posts: 97
Reputation: 9

Message # 3 | 1:42 AM
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
Cartman
Posts: 31
Reputation: 2

Message # 4 | 5:55 PM
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:
-comments
-news
-publisher
-links

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
kostova
Posts: 97
Reputation: 9

Message # 5 | 7:48 PM
Try a 0 instead of len().
That might solve the problem. You're just trying to get the User ID right?
Cartman
Posts: 31
Reputation: 2

Message # 6 | 11:31 PM
kostova, thx but doesn't work. It only gives empty, zero long strings then.

kostova
Posts: 97
Reputation: 9

Message # 7 | 0:46 AM
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
ex: http://www.yoursitename.com/index/8- returns 36
code: <?substr($PROFILE_URL$, 36)?> returns the user id of the commenter - replace 36 with your own number.

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
Natashko
Posts: 3366
Reputation: 171

Message # 8 | 4:15 PM
Cartman, to substract the UserID form the ProfileUrl try this:
Code
<?substr(substr($PROFILE_URL$, strpos($PROFILE_URL$,'-')+1),0,strpos(substr($PROFILE_URL$, strpos($PROFILE_URL$,'-')+1),'\''))?>
uCoz Community » uCoz Modules » Forum » Thanks button with conditional operators (How to get User ID form Profile Url)
  • Page 1 of 1
  • 1
Search: