Results 1 to 2 of 2
  1. #1
    New Pligger sturko's Avatar
    Joined
    Sep 2009
    Posts
    19

    programing function in module question / help!

    In simple messaging module in compose view i want to add list of users that are my friends.
    In simple_messaging_main.php i added :
    Code:
    function get_friend_list()
    				{	
    					global $db, $the_template, $current_user, $main_smarty;
    					$sql = "SELECT " . table_users . ".user_login 
    											 FROM " . table_friends . " 
    											 INNER JOIN " . table_users . " 
    											 ON " . table_friends . ".friend_to = " . table_users . ".user_id 
    											 WHERE (((" . table_friends . ".friend_from)= " . $current_user->user_id . "))";
    					
    					$friends = $db->get_results($sql);
    					$friends = object_2_array($friends);
    					return $friends;
    			}
    and
    Code:
    $main_smarty->assign('m_get_friend_list', get_friend_list($current_user->user_id));
    in compose.tpl:
    Code:
          {foreach from=$m_get_friend_list item=foo}
                        {$foo}
                    {/foreach}
    If you have for example 3 friends, on the compose page it shows word Array 3 times ("Array Array Array") not names of the friends.

    If i use return $voters[0]; in function it shows the name of first friend normally (Marko), doesent list "Array".
    If i use same function and foreach loop on any other page like for example user.php it works normally and shows for example "Marko, Luigi, Francis", not "Array Array Array".

    Why is this the case in this module ? I am not a programmer, just need this simple addon.

    Do anybody know how to fix this?

    Thanks!

  2. #2
    New Pligger sturko's Avatar
    Joined
    Sep 2009
    Posts
    19
    Quote Originally Posted by sturko View Post
    In simple messaging module in compose view i want to add list of users that are my friends.
    .........
    Do anybody know how to fix this?

    Thanks!
    Ok, i found the solution, it was right in front of my nose, section loop with .user_login, not foreach:

    {section name=nr loop=$m_get_friend_list}
    {$m_get_friend_list[nr].user_login}<br />
    {/section}

Similar Threads

  1. Assign Smarty vars from Module function
    By edoher in forum Questions & Comments
    Replies: 10
    Last Post: 06-03-2010, 10:14 AM
  2. Question about the IPB module
    By sylvere_brun in forum Questions & Comments
    Replies: 5
    Last Post: 03-01-2010, 02:31 PM
  3. Upload Module & RSS Importer Question
    By user1500 in forum Questions & Comments
    Replies: 2
    Last Post: 07-16-2009, 03:56 PM
  4. Upload Module & RSS Importer Question
    By user1500 in forum Questions & Comments
    Replies: 0
    Last Post: 07-12-2009, 09:50 AM
  5. Adsense module question
    By theozard in forum Questions & Comments
    Replies: 1
    Last Post: 04-13-2007, 06:28 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 Donate to Pligg CMS Dreamhost Web Hosting Host Gator Web Hosting