Support I want to create a custom phrase for custom page

Compatible XF Versions
2.3.3

farukduyarl

Registered
Hello,

I'm running XenForo version 2.3.3 and have created a subdirectory called `/test` within my installation. Inside this folder, I placed a basic `index.php` file and successfully included XenForo's core by loading `config.php`. After running some tests, I confirmed that I can access the XenForo framework and the database without any issues.

What I would like to achieve is the following:

When a user visits `/test/index.php`, I want XenForo to update their "Last seen" activity and display a custom activity message such as “Viewing the Test index”. In other words, I want the user’s online status to show something more specific than just "last seen recently" — it should reflect that they're viewing this particular page.

How can I implement this functionality?

Thank you in advance!
 

robertjulia

Registered
To achieve the functionality you're looking for in your XenForo installation, you can use the XenForo_Application::getInstance()->getSession() method to update the user's last seen activity. Here’s a brief outline of the steps you can take:
Include the necessary XenForo files at the beginning of your index.php.
Update the user’s last activity using the session object.
Set a custom activity message to reflect the specific page being viewed.
Here’s a sample code snippet you can add to your index.php:
Copy
// Include XenForo's core
require('path/to/XenForo/config.php');
// Get the session
$session = XenForo_Application::getInstance()->getSession();
// Update last activity
$session->set('lastActivity', time());
$session->set('customActivityMessage', 'Viewing the Test index');
// Save changes
$session->save();
Make sure to replace 'path/to/XenForo/config.php' with the actual path to your XenForo config file.
This should help you achieve the desired functionality. Let me know if you have any questions or need further assistance!
iq test free
 

finnbentley

Registered
Make sure your index.php in the /test directory correctly includes the XenForo framework and initializes the application. You might already have this set up, but here’s a basic outline: io games
<?php
// Define the XenForo root path
define('XF_ROOT', dirname(__DIR__));

// Include the necessary XenForo files
require_once XF_ROOT . '/src/XF.php';
require_once XF_ROOT . '/src/config.php';

// Initialize the application
$app = \XF::app();
You need to update the user's last seen activity when they access your custom page. You can do this by using the \XF\Entity\User class to set the activity.
 
Back
Top Bottom