FAQ modułów
Często zadawane pytania dotyczące modułów
Dział zatytułowany „Często zadawane pytania dotyczące modułów”Typowe pytania i odpowiedzi dotyczące modułów XOOPS, instalacji i zarządzania.
Installation & Activation
Dział zatytułowany „Installation & Activation”Q: How do I install a module in XOOPS?
Dział zatytułowany „Q: How do I install a module in XOOPS?”A:
- Download the module zip file
- Go to XOOPS Admin > Modules > Manage Modules
- Click “Browse” and select the zip file
- Click “Upload”
- The module appears in the list (usually deactivated)
- Click the activation icon to enable it
Alternatively, extract the zip directly into /xoops_root/modules/ and navigate to the admin panel.
Q: Module upload fails with “Permission denied”
Dział zatytułowany „Q: Module upload fails with “Permission denied””A: This is a file permission issue:
# Fix module directory permissionschmod 755 /path/to/xoops/modules
# Fix upload directory (if uploading)chmod 777 /path/to/xoops/uploads
# Fix ownership if neededchown -R www-data:www-data /path/to/xoopsSee Module Installation Failures for more details.
Q: Why can’t I see the module in the admin panel after installation?
Dział zatytułowany „Q: Why can’t I see the module in the admin panel after installation?”A: Check the following:
- Module not activated - Click the eye icon in Modules list
- Missing admin page - Module must have
hasAdmin = 1in xoopsversion.php - Language files missing - Need
language/english/admin.php - Cache not cleared - Clear cache and refresh browser
# Clear XOOPS cacherm -rf /path/to/xoops/xoops_data/caches/*Q: How do I uninstall a module?
Dział zatytułowany „Q: How do I uninstall a module?”A:
- Go to XOOPS Admin > Modules > Manage Modules
- Deactivate the module (click the eye icon)
- Click the trash/delete icon
- Manually delete the module folder if you want complete removal:
rm -rf /path/to/xoops/modules/modulenameModule Management
Dział zatytułowany „Module Management”Q: What’s the difference between disabling and uninstalling?
Dział zatytułowany „Q: What’s the difference between disabling and uninstalling?”A:
- Disable: Deactivate the module (click eye icon). Database tables remain.
- Uninstall: Remove the module. Deletes database tables and removes from list.
To truly remove, also delete the folder:
rm -rf modules/modulenameQ: How do I check if a module is properly installed?
Dział zatytułowany „Q: How do I check if a module is properly installed?”A: Use the debug script:
<?php// Create admin/debug_modules.phprequire_once XOOPS_ROOT_PATH . '/mainfile.php';
if (!is_object($xoopsUser) || !$xoopsUser->isAdmin()) { exit('Admin only');}
echo "<h1>Module Debug</h1>";
// List all modules$module_handler = xoops_getHandler('module');$modules = $module_handler->getObjects();
foreach ($modules as $module) { echo "<h2>" . $module->getVar('name') . "</h2>"; echo "Status: " . ($module->getVar('isactive') ? "Active" : "Inactive") . "<br>"; echo "Directory: " . $module->getVar('dirname') . "<br>"; echo "Mid: " . $module->getVar('mid') . "<br>"; echo "Version: " . $module->getVar('version') . "<br>";}?>Q: Can I run multiple versions of the same module?
Dział zatytułowany „Q: Can I run multiple versions of the same module?”A: No, XOOPS doesn’t support this natively. However, you can:
- Create a copy with a different directory name:
mymoduleandmymodule2 - Update the dirname in both modules’ xoopsversion.php
- Ensure unique database table names
This is not recommended as they share the same code.
Module Configuration
Dział zatytułowany „Module Configuration”Q: Where do I configure module settings?
Dział zatytułowany „Q: Where do I configure module settings?”A:
- Go to XOOPS Admin > Modules
- Click the settings/gear icon next to the module
- Configure preferences
Settings are stored in the xoops_config table.
Access in code:
<?php$module_handler = xoops_getHandler('module');$module = $module_handler->getByDirname('modulename');$config_handler = xoops_getHandler('config');$settings = $config_handler->getConfigsByCat(0, $module->mid());
foreach ($settings as $setting) { echo $setting->getVar('conf_name') . ": " . $setting->getVar('conf_value');}?>Q: How do I define module configuration options?
Dział zatytułowany „Q: How do I define module configuration options?”A: In xoopsversion.php:
<?php$modversion['config'] = [ [ 'name' => 'items_per_page', 'title' => '_AM_MYMODULE_ITEMS_PER_PAGE', 'description' => '_AM_MYMODULE_ITEMS_PER_PAGE_DESC', 'formtype' => 'text', 'valuetype' => 'int', 'default' => 10 ], [ 'name' => 'enable_feature', 'title' => '_AM_MYMODULE_ENABLE_FEATURE', 'description' => '_AM_MYMODULE_ENABLE_FEATURE_DESC', 'formtype' => 'yesno', 'valuetype' => 'bool', 'default' => 1 ]];?>Module Features
Dział zatytułowany „Module Features”Q: How do I add an admin page to my module?
Dział zatytułowany „Q: How do I add an admin page to my module?”A: Create the structure:
modules/mymodule/├── admin/│ ├── index.php│ ├── menu.php│ └── menu_en.phpIn xoopsversion.php:
<?php$modversion['hasAdmin'] = 1;$modversion['adminindex'] = 'admin/index.php';?>Create admin/index.php:
<?phprequire_once XOOPS_ROOT_PATH . '/kernel/admin.php';
xoops_cp_header();echo "<h1>Module Administration</h1>";xoops_cp_footer();?>Q: How do I add search functionality to my module?
Dział zatytułowany „Q: How do I add search functionality to my module?”A:
- Set in xoopsversion.php:
<?php$modversion['hasSearch'] = 1;$modversion['search'] = 'search.php';?>- Create
search.php:
<?phpfunction mymodule_search($queryArray, $andor, $limit, $offset) { // Search implementation $results = []; return $results;}?>Q: How do I add notifications to my module?
Dział zatytułowany „Q: How do I add notifications to my module?”A:
- Set in xoopsversion.php:
<?php$modversion['hasNotification'] = 1;$modversion['notification_categories'] = [ ['name' => 'item_published', 'title' => '_NOT_ITEM_PUBLISHED']];$modversion['notifications'] = [ ['name' => 'item_published', 'title' => '_NOT_ITEM_PUBLISHED']];?>- Trigger notification in code:
<?php$notification_handler = xoops_getHandler('notification');$notification_handler->triggerEvent( 'item_published', $item_id, 'Item published', 'description');?>Module Permissions
Dział zatytułowany „Module Permissions”Q: How do I set module permissions?
Dział zatytułowany „Q: How do I set module permissions?”A:
- Go to XOOPS Admin > Modules > Module Permissions
- Select the module
- Choose user/group and permission level
- Save
In code:
<?php// Check if user can access moduleif (!xoops_isUser()) { exit('Login required');}
// Check specific permission$mperm_handler = xoops_getHandler('member_permission');$module_handler = xoops_getHandler('module');$module = $module_handler->getByDirname('mymodule');
if (!$mperm_handler->userCanAccess($module->mid())) { exit('Access denied');}?>Module Database
Dział zatytułowany „Module Database”Q: Where are module database tables stored?
Dział zatytułowany „Q: Where are module database tables stored?”A: All in the main XOOPS database, prefixed with your table prefix (usually xoops_):
# List all module tablesmysql> SHOW TABLES LIKE 'xoops_mymodule_%';
# Or in PHP<?php$result = $GLOBALS['xoopsDB']->query( "SHOW TABLES LIKE '" . XOOPS_DB_PREFIX . "mymodule_%'");while ($row = $result->fetch_assoc()) { print_r($row);}?>Q: How do I update module database tables?
Dział zatytułowany „Q: How do I update module database tables?”A: Create an update script in your module:
<?phprequire_once '../../mainfile.php';
if (!is_object($xoopsUser) || !$xoopsUser->isAdmin()) { exit('Admin only');}
// Add new column$sql = "ALTER TABLE `" . XOOPS_DB_PREFIX . "mymodule_items` ADD COLUMN `new_field` VARCHAR(255)";
if ($GLOBALS['xoopsDB']->query($sql)) { echo "✓ Updated successfully";} else { echo "✗ Error: " . $GLOBALS['xoopsDB']->error;}?>Module Dependencies
Dział zatytułowany „Module Dependencies”Q: How do I check if required modules are installed?
Dział zatytułowany „Q: How do I check if required modules are installed?”A:
<?php$module_handler = xoops_getHandler('module');
// Check if a module exists$module = $module_handler->getByDirname('required_module');
if (!$module || !$module->getVar('isactive')) { die('Error: required_module is not installed or active');}?>Q: Can modules depend on other modules?
Dział zatytułowany „Q: Can modules depend on other modules?”A: Yes, declare in xoopsversion.php:
<?php$modversion['dependencies'] = [ [ 'dirname' => 'required_module', 'version_min' => '1.0', 'version_max' => 0, // 0 = unlimited 'order' => 1 ]];?>Troubleshooting
Dział zatytułowany „Troubleshooting”Q: Module appears in list but won’t activate
Dział zatytułowany „Q: Module appears in list but won’t activate”A: Check:
- xoopsversion.php syntax - Use PHP linter:
php -l modules/mymodule/xoopsversion.php- Database SQL file:
# Check SQL syntaxgrep -n "CREATE TABLE" modules/mymodule/sql/mysql.sql- Language files:
ls -la modules/mymodule/language/english/See Module Installation Failures for detailed diagnostics.
Q: Module activated but doesn’t show in main site
Dział zatytułowany „Q: Module activated but doesn’t show in main site”A:
- Set
hasMain = 1in xoopsversion.php:
<?php$modversion['hasMain'] = 1;$modversion['main_file'] = 'index.php';?>- Create
modules/mymodule/index.php:
<?phprequire_once '../../mainfile.php';include_once XOOPS_ROOT_PATH . '/header.php';
echo "Welcome to my module";
include_once XOOPS_ROOT_PATH . '/footer.php';?>Q: Module causes “white screen of death”
Dział zatytułowany „Q: Module causes “white screen of death””A: Enable debugging to find the error:
<?php// In mainfile.phperror_reporting(E_ALL);ini_set('display_errors', '1');define('XOOPS_DEBUG_LEVEL', 2);?>Check the error log:
tail -100 /var/log/php/error.logtail -100 /var/log/apache2/error.logSee White Screen of Death for solutions.
Performance
Dział zatytułowany „Performance”Q: Module is slow, how do I optimize?
Dział zatytułowany „Q: Module is slow, how do I optimize?”A:
- Check database queries - Use query logging
- Cache data - Use XOOPS cache:
<?php$cache = xoops_cache_handler::getInstance();$data = $cache->read('mykey');if ($data === false) { $data = expensive_operation(); $cache->write('mykey', $data, 3600); // 1 hour}?>- Optimize templates - Avoid loops in templates
- Enable PHP opcode cache - APCu, XDebug, etc.
See Performance FAQ for more details.
Module Development
Dział zatytułowany „Module Development”Q: Where can I find module development documentation?
Dział zatytułowany „Q: Where can I find module development documentation?”A: See:
- Module Development Guide
- Module Structure
- Creating Your First Module
Related Documentation
Dział zatytułowany „Related Documentation”- Module Installation Failures
- Module Structure
- Performance FAQ
- Enable Debug Mode
#xoops #modules #faq #troubleshooting