Customizing SMF > Tips and Tricks

[TRICK] displaying the "unknown action" in the who's online list

<< < (9/10) > >>

OzzyMozzy:
That's ok at least it's not saying Unknown action anymore. thanks heaps

ChalkCat:
Hi, me again!  As I've said earlier in this topic, this trick is working great for me.  However, I decided to sort out my error logs, so I deleted all errors, went about my business and checked back.  Within a few minutes of leaving my computer on the auto-refreshing Who's Online, I had 30 instances of this error:


--- Quote ---http://******.com/index.php?action=who
8: Undefined variable: scripturl
File: /home/content/**/*******/html/******/Sources/Who.php
Line: 451
--- End quote ---

Line 451 is this:


--- Code: ---// Unlisted or unknown action.
else
$data[$k] = $txt['who_thisaction'] . '<a href="' . $scripturl . '?action=' . $actions['action'] . '">' . $actions['action'] . '</a>';

--- End code ---

Please can you help me stop this error from occurring, or is everyone else getting it and it's just something I have to accept?  As I said, there are no problems with the trick itself, it does exactly what it should.

Thank you  :)

Kindred:
Hmmmmm... Really? Wonder why it does not trigger that for me.

Anyway, simple fix. Add
 global $scripturl;
Up above... At the start of the function, where the other global declarations are

ChalkCat:
Thanks Kindred, I think I've put it in the right place  ;)

Just emptied my error log again so I'll see what appears now.  Thanks for the fast response  :)

Kindred:
now that I can get to my code from an actual computer:


--- Code: (find in Sources/Who.php) ---function determineActions($urls, $preferred_prefix = false)
{
  global $txt, $user_info, $modSettings, $smcFunc, $context;

--- End code ---


--- Code: (add after) ---global $scripturl;

--- End code ---

edit- after looking through the code, I wonder why this error was not noticed before...   because, in the core, unedited code, it looks like $scripturl is not actually defined in the determineActions function. It must have been added by another mod to my code and I missed it for the trick.   Original code in the first post has been edited.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version