hey guys
I have non-forum pages, SSI.php included.
I've checked if someone is visitign page x.html , the forum says he is viewing the index board of the site.
How can i make it so that the forum says he is visiting x.html ?
I played a little with $context['current_action'] on the x.html , before and after including SSI ,But has no success.
same with total time logged. When the user is in the x.html page, he total time logged won't increase, How can i achieve that too?
Thanks
SMF 1.1.6
*bump*
To make forum to count the SSI page as online too, add this code after you include SSI.php:
writeLog();
To make forum to recognize where you are, add this code before you include SSI.php:
$_GET['action'] = 'my_page';
Then add this at the end of your Who.template.php file:
$txt['whoall_my_page] = 'He\'s viewing my page.';
Thanks for replying man, I got the members visiting pages right.
But total time logged still doesn't work.
I added writeLog(); after SSI being included, and stayed in some pages for like 2-3 mins , and refreshed, still no change, any idea?
I see, total time online won't increase if you are using SSI.
Subs.php
Find:
if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60)
Replace:
if (!empty($user_info['last_login']) && $user_info['last_login'] < time() - 60)
Do not forget this edit, you may need to take it back for upgrades.
it worked! I cannot believe it :D
Thanks man, Don't know how to thank you, Thanks A TON!
Great advice Sinan! I've copied notes from this topic and I'm sure I'm going to need it before long. :)
Quote from: [SiNaN] on October 24, 2008, 11:54:13 AM
To make forum to count the SSI page as online too, add this code after you include SSI.php:
writeLog();
To make forum to recognize where you are, add this code before you include SSI.php:
$_GET['action'] = 'my_page';
Then add this at the end of your Who.template.php file:
$txt['whoall_my_page] = 'He\'s viewing my page.';
Just wondering if this script is good for use in SMF V2?
It should be.
seems I got a problem with "who's online" .
my non forum files work like this :
index.php?file=file1
so I have $_GET['file'] .
I've tested it, it works WHEN there's no $_GET variable set, meaning when I'm on my home page where there's no $_GET variable it works,
BUT when i'm in the index.php?file=file1 , it says I'm on index of forum page which means it kinda has been disabled.
What's wrong with it?
*bump*
Would having a single action for all SSI pages work for you?
unfortunately no.
I have a lot of SSI pages. That their $_GET['action'] are all different.
What should I ? I'll go down that road, just tell me :)
Well, let's try this.
Subs.php
Find:
function writeLog($force = false)
Replace:
function writeLog($force = false, $ssi_action = null)
Find:
$serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
Replace:
$serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
if (!empty($ssi_action))
$serialized['action'] = $ssi_action;
Then in your SSI included file, use writeLog(false, 'action_you_want_to_be_save'); instead of just writeLog();. Example: writeLog(false, 'my_page);
It worked ! FINALLY ! I don't know what to say :D
just to sum it up for others :
do exactly as [SiNaN] said. but remember the $_GET['action'] = 'my_page'; and the $txt['whoall_my_pages'] = 'He\'s viewing the page';
must be in their places still.
[SiNaN], Dont' know how to thank you. It was driving me crazy!
Thanks!
P.S (I promise it is the last one :D ) If a page has its own variable,for example ,
we are both visiting "edit" page and you are editing "A" team stat, I'm editing "B" team stat. something like the way forum do wit topics .
I want it to say : SiNaN is editing "A" team stat.
Asmith is editing "B" team stat.
how should I pass "A" or "B" to $txt variable? something to do with those %s ?
This might work:
Who.php
Find:
// An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.)
Replace:
elseif (substr($actions['action'], 0, 8) == 'my_page_')
$data[$k] = sprintf($txt['whoall_my_page'], substr($actions['action'], 8));
// An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.)
Then you text string will be:
$txt['whoall_my_page'] = 'Editing "%s" team stats.';
When you set the action in SSI, set you should set it as; my_page_{team_name}
Example:
$_GET['action'] = 'my_page_A';
If you want to change 'my_page' part, you should modify the codes accordingly.
:) Got nothing to say!
You're awsome!
btw congrats on your new nick, finally got rid of 'Extremely Depressed' ? ;)
Well, not really; trying to get along with it. :P
Glad that I could help and thanks. ;)
Came up with a new question :D lol this thread can never get closed !
emm does this thing we did to other pages, has any effect on "who's viewing this page" ?
You know when viewing a topic on the top it is written "asmith and 4 guests are viewing this topic" (If this option is turned on in admin of course)
How can I put it on my non-forum pages?
I think the changes we did has something to do with this.
any idea?
You mean this causes a problem with that function? I don't think so.
No, it is working perfect.
I mean, this thing we can make it on in admin page that it show which people are watching a topic. for example it says on the top of the topic : Blue Dream, Asmith and 4 guests are viewing this topic.
I thought maybe I could put such thing on my non-forum pages. Is there a function for that ? If not maybe I can do it by writing an script with logs table?
I'm checking with you if there's a better way with smf functions, rather than I write an script myself in eahc page, checking the data in logs table.
Yeah, you can do that. You can cheat from SMF. Look for "// Nosey, nosey - who's viewing this topic?" line and the block under it, in MessadIndex.php file. You will see the codes to fetch who's viewing.
WARNING!!
After beating my head for a few days (which made a surprising change, I can tell you!) I found out my problem!
I tried to add some custom actions to the who's online thing, but found they were not showing up!
I found with some trial and error, that if I set the action to something that was already in the who.english.... file, that THOSE actions were reflected in the who's online, and then...
:( grrr.... YOU HAVE TO CLEAR THE CACHE!!!!!
index.php?action=admin;area=maintain;sa=routine;activity=cleancache