Results 1 to 7 of 7
  1. #1
    Constant Pligger tbones's Avatar
    Joined
    Apr 2007
    Posts
    1,042
    Thanks
    Received:1
    Given: 0

    Pligg variable definition and SQL query for an existing variable

    Hi,

    I´ve tried the following in yget/user_center.tpl:
    Code:
    <tr>
    <td><strong>{#PLIGG_Visual_User_Profile_Total_Votes#}:</strong></td>
    				$percent = round($user_total_votes/$queued), 2)
    				<td>{$user_total_votes} ({$percent} %)</td>
    </tr>
    Can you tell me how to define the variable correctly or display the percentage value in another way? $queued has its origin here: http://forums.pligg.com/pligg-mods/7...html#post32127

    Furthermore, I can´t find the SQL query that defines $user_total_votes because I want to limited the count to certain categories.

    Thank you for your help!

  2. #2
    Pligg Donor beatniak's Avatar
    Joined
    Apr 2006
    Posts
    197
    Thanks
    Received:0
    Given: 0
    1) You can't just throw php code in your HTML.
    Whatever you are trying to, put that php code between {php} and {/php} when you want to use php code in tpl files
    so smarty knows that you want to interpret it as php.

    2) you can't use {$percent} if you haven't passed that variable to smarty. So give that variable to smarty in the php.

    To sum up, do something like this:
    Code:
    <tr>
    <td><strong>{#PLIGG_Visual_User_Profile_Total_Votes#}:</strong></td>
    {php}
    $percent = round($user_total_votes/$queued), 2);
    $main_smarty->assign('percent', '$percent');
    {/php}
    <td>{$user_total_votes} ({$percent} &#37;)</td>
    </tr>

  3. #3
    Constant Pligger tbones's Avatar
    Joined
    Apr 2007
    Posts
    1,042
    Thanks
    Received:1
    Given: 0
    Hi beatniak,
    thank you for your help!

    If I try that code I get:

    Parse error: syntax error, unexpected ',' in domain.com/class.template.php(745) : eval()'d code on line 590

    It works fine without the php part (except of the non-existing result ;-) ). I´ve tried to put this part in smartyvariables.php but without any success. I guess I have to place it near to the SQL query for $user_total_votes.

  4. #4
    Constant Pligger tbones's Avatar
    Joined
    Apr 2007
    Posts
    1,042
    Thanks
    Received:1
    Given: 0
    kb told me the location user.php. Thanks!

    If&#180;ve tried to define it there as
    $this->percent = round(($user_total_votes/$queued), 2)
    but with the same result as above.

  5. #5
    Constant Pligger tbones's Avatar
    Joined
    Apr 2007
    Posts
    1,042
    Thanks
    Received:1
    Given: 0
    Anyone a clue how to define the variable?

  6. #6
    Constant Pligger savant's Avatar
    Joined
    Apr 2006
    Posts
    1,181
    Thanks
    Received:0
    Given: 0
    in php you do not need to define a variable like in C ...

    doing $variable =10; means $variable is defined.

  7. #7
    Constant Pligger tbones's Avatar
    Joined
    Apr 2007
    Posts
    1,042
    Thanks
    Received:1
    Given: 0
    What is the right file of file type to define it, php or tpl?

    Please don&#180;t misunderstand that as hijacking :-) If so, just ignore it!
    Here is an even more important problem to me with $amIgod:
    http://forums.pligg.com/bug-report/8...passwords.html

Similar Threads

  1. Help with PHP - Strip variable
    By mateusmoraes in forum Questions & Comments
    Replies: 6
    Last Post: 09-13-2007, 08:05 AM
  2. reading pligg "variable" into php code - variable assignment
    By aprathivadi in forum Questions & Comments
    Replies: 0
    Last Post: 06-05-2007, 12:18 AM
  3. pligg variable ip
    By argh2xxx in forum Questions & Comments
    Replies: 0
    Last Post: 02-10-2007, 09:57 PM
  4. one variable for 'pligg' word
    By rex in forum Questions & Comments
    Replies: 5
    Last Post: 10-09-2006, 07:11 AM
  5. URL rewrite and variable definition errors
    By rohanpinto in forum Questions & Comments
    Replies: 3
    Last Post: 09-27-2006, 03:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Pligg Modules and Pligg Templates from Pligg Pro Web Hosting Services by Midphase Dreamhost Web Hosting Donate to Pligg