1
ian-m
Re: Display username and avatar in a block?
  • 2004/7/2 22:19

  • ian-m

  • Just popping in

  • Posts: 7

  • Since: 2004/6/29


Ah, I wasn't clear on what could and could not be done. I assumed this would be a fairly common thing to do. I'll take a look at this later on, thanks for the pointers.



2
ian-m
Re: Display username and avatar in a block?
  • 2004/7/2 15:40

  • ian-m

  • Just popping in

  • Posts: 7

  • Since: 2004/6/29


Well, now that I've had more time to actually give my code a shot, I see that it doesn't work because of a fairly obvious html mistake that I managed to miss (I intended to create a link with the avatar image, but I left out echo "</a>"; at the end. Oops.)

Though, now I have a strange problem I don't understand.

When I put "echo $xoopsUser->getVar('uname');" I get a blank page in a block, regardless if anything else is in the block, I get "Fatal error: Call to a member function on a non-object in /home/(removed)/public_html/class/xoopsblock.php(146) : eval()'d code on line 1"

Do I need to modify xoopsblock.php to include some function to get at these variables? The wiki refers to modules, but this is just a simple block, so that would be my guess, but I don't know where to start on that. Thanks for any help.



3
ian-m
Re: Display username and avatar in a block?
  • 2004/7/2 14:17

  • ian-m

  • Just popping in

  • Posts: 7

  • Since: 2004/6/29


I'm working on this as well. It most likely can't be done with just html, but if you put in some php to query your database you should be able to pull out the path. I haven't put this into action on my server yet, but here's an idea using what you've got:
// first you want the username, so that's what you had above:

echo "<a href='http://www.pagename.com/userinfo.php?uid=idnumber'>";

// next you need to connect to the database with your xoops
// user (or any user with select privileges on the XOOPS db

// obviously replace with real values
$db mysql_connect('localhost''your_xoops_user''your_pass'); 

// again replace with real value
mysql_select_db('your_xoops_db'$db);

// form your sql query
$query "SELECT user_avatar FROM xoops_users WHERE uid=some_number";

// ask
$answer mysql_query($query$db);

// if there's an error you should make some kind of default
if(!$answer){
  echo 
"<img src='default.jpg'>";
}

// I'm planning on fetching multiple data, so I wrote it
// this way, you could probably do it some other way though

$array mysql_fetch_array($answer);

// this is different depending on how and where you've
// stored the avatars, by default avatars are stored in your
// http://yourxoopssite.com/uploads/

echo "<img src='http://yourxoopssite.com/uploads/".$array['user_avatar']."'>";


That should do it, but again, I haven't put this in place yet myself (and I'm relatively new to php/mysql).

Hope this helps, good luck!



4
ian-m
Re: Installing Avatars
  • 2004/7/1 18:42

  • ian-m

  • Just popping in

  • Posts: 7

  • Since: 2004/6/29


I'll go ahead and make some modifications to it then and put a tarball online. It's not integrated especially nicely into XOOPS or anything, but it did work for me. I'll see what I can do to make it more user friendly in the next hour or so (the beauty of being unemployed ). Check back later and I should have a download URL with instructions posted. Also, there's a hack someone made:https://xoops.org/modules/newbb/viewtopic.php?topic_id=15945&forum=14 but, I didn't find that until after I finished my script. I'll still make my stuff available online though in the hopes someone will think it's useful



5
ian-m
Re: Installing Avatars
  • 2004/7/1 18:15

  • ian-m

  • Just popping in

  • Posts: 7

  • Since: 2004/6/29


You'll want to read through the sql file and make sure the database information is correct for your system. In short, if you've got an sql file you can either login to your database with "mysql -u your_user -p 'your_pass'" and then once at the prompt, you'll want to "USE your_xoops_db;" and then "SOURCE '/path/to/file.sql';" Alternatly, you can add the "USE your_xoops_db;" to the sql file and then just run "mysql -u your_user -p 'your_pass' < file.sql" at the shell level. If you don't have this kind of access with your hosting provider, then I'm not sure how you'd go about doing this, you'd have to check your documentation.

In my attempts to learn php and MySQL I ended up writing a sql script generating php script to add avatars to the XOOPS database automatically. If there's interest I'll make this available :).

Hope this helps.



6
ian-m
Re: php in block
  • 2004/6/29 23:57

  • ian-m

  • Just popping in

  • Posts: 7

  • Since: 2004/6/29


Thank you for your very fast reply. Enabling this allowed me to track down the problem very quickly and get my code working again. My problem had to do with lots of <?php echo $var; ?> statements embedded within some html for the formatting that (for whatever reason) I was ignoring. Modifying my code to echo the html instead fixed everything.

Thanks again,
Ian



7
ian-m
Re: php in block
  • 2004/6/29 23:36

  • ian-m

  • Just popping in

  • Posts: 7

  • Since: 2004/6/29


I'm also having this problem, and I have yet to figure it out. I'm not adding the <?php and ?> to the script, content type is set to "PHP Script" and the script works when I put it in a new file and just have the plain text load. I've tried a simple include() of the seperate file, that also doesn't work. I'd post errors, but none get printed to the page, so I can't. This is rather frustrating. Further testing shows that putting anything in the block while it is selected as PHP Script will not execute or print to the screen.




TopTop



Login

Who's Online

146 user(s) are online (115 user(s) are browsing Support Forums)


Members: 0


Guests: 146


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits