Hi Gurus
In Kongondo’s wayfinder ebook, ch15- JQuery accordion Wayfinder menu - i tried implementing it as a test.
Issue:
I have 3 menus - recent, active, inactive.
In active menu, there are 2 files, named a and b
In inactive menu, there is 1 file named c
User logs in and clicks files a and c to see their content and logs out.
User logs in again, the recent menu should display files a and c as part of its files.
How do I accomplish that with wayfinder or is there another approach to solve this ?
I thought about copying the files a and c to recent folder.
But the problem is that each user would have different files accessed.
Moreover, how can i accomplish this automatically by script or otherwise as opposed to manual copy from the manager ?
Thank you in advance for your thoughts and proposed solution.
Sincerely
-
☆ A M B ☆
- 24,524 Posts
You’re going to have to store the user’s activity somehow. This means a custom database application; this is a perfect occasion to use a plugin. The table would need at least three fields, $modx->getLoginUserID() (user ID), $modx->documentIdentifier (resource ID of the current page), and date. The plugin could be written to only do its thing when the page being accessed has a certain parent (or ultimate parent) so it doesn’t record access to the home page and other pages you aren’t interested in recording.
Then the "recent" menu would be generated from this table, using the ID of the logged-in user to get the IDs of the pages he accessed in chronological order and feed them to the $modx->makeUrl($id) API function. A snippet would do fine for this.
Hi Susan
Thanks for your response.
I’m new to MODx and slow to understand your solution.
I played a little more and found out that on the manager itself when one clicks
Site-Home-Recent Resources, it displays the list of recently accessed files.
I also found out that there’s ListIndxer
[[ListIndexer?LIn_root=53,54 &LIn_sQty=5]]
But ListIndexer only displays files based on published date in the database, not accessed date, which is a more recent date.
So could the MODx team share how they did it with Site-Home-Recent Resources ?
Could we borrow their snippet ?
-
☆ A M B ☆
- 24,524 Posts
That is taken from the active_users table. It keeps track of the latest actions in the Manager. It keeps track of Manager actions (such as editing a resource, or looking at the Configuration).
As far as I can tell, the only time it keeps track of web user actions is when the web user is redirected to a "login home page" as part of the login process, in that case it records the page he was redirected to.
A list of "actions" is in the manager/includes/actionlist.inc.php, and this has ’998’=>’Viewing web page’.
The web user ID is stored as a negative number, so a web user with an ID of 3 and a username of "visitor" redirected to document #42 would have the following fields inserted into the database:
internalKey = -3
username = visitor
lasthit = UNIX timestamp
id = 42
action = 998
ip = visitor’s IP address
This is done by the WebLogin snippet. Subsequent logins overwrite the timestamp.
The WebLoginPE snippet uses this record of logins to determine if a user is logged in (for its "Who’s Online" feature), and sets the timestamp to 0 on logout.
But there is no mechanism for keeping track of pages a user views. You would need a plugin to do that. It could use the same table, but this table needs to be emptied from time to time with the Manager in the Reports -> Manager Actions menu, or it can get quite large. It would be better to use a custom table for this purpose, and have a mechanism for keeping it within a reasonable size. It would just overwrite the date of access if the document ID already exists for that user, for example.