Przejdź do głównej zawartości

FAQ modułów

Typowe pytania i odpowiedzi dotyczące modułów XOOPS, instalacji i zarządzania.


A:

  1. Download the module zip file
  2. Go to XOOPS Admin > Modules > Manage Modules
  3. Click “Browse” and select the zip file
  4. Click “Upload”
  5. The module appears in the list (usually deactivated)
  6. Click the activation icon to enable it

Alternatively, extract the zip directly into /xoops_root/modules/ and navigate to the admin panel.


A: This is a file permission issue:

Okno terminala
# Fix module directory permissions
chmod 755 /path/to/xoops/modules
# Fix upload directory (if uploading)
chmod 777 /path/to/xoops/uploads
# Fix ownership if needed
chown -R www-data:www-data /path/to/xoops

See 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:

  1. Module not activated - Click the eye icon in Modules list
  2. Missing admin page - Module must have hasAdmin = 1 in xoopsversion.php
  3. Language files missing - Need language/english/admin.php
  4. Cache not cleared - Clear cache and refresh browser
Okno terminala
# Clear XOOPS cache
rm -rf /path/to/xoops/xoops_data/caches/*

A:

  1. Go to XOOPS Admin > Modules > Manage Modules
  2. Deactivate the module (click the eye icon)
  3. Click the trash/delete icon
  4. Manually delete the module folder if you want complete removal:
Okno terminala
rm -rf /path/to/xoops/modules/modulename

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:

Okno terminala
rm -rf modules/modulename

A: Use the debug script:

<?php
// Create admin/debug_modules.php
require_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>";
}
?>

A: No, XOOPS doesn’t support this natively. However, you can:

  1. Create a copy with a different directory name: mymodule and mymodule2
  2. Update the dirname in both modules’ xoopsversion.php
  3. Ensure unique database table names

This is not recommended as they share the same code.


A:

  1. Go to XOOPS Admin > Modules
  2. Click the settings/gear icon next to the module
  3. 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');
}
?>

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
]
];
?>

A: Create the structure:

modules/mymodule/
├── admin/
│ ├── index.php
│ ├── menu.php
│ └── menu_en.php

In xoopsversion.php:

<?php
$modversion['hasAdmin'] = 1;
$modversion['adminindex'] = 'admin/index.php';
?>

Create admin/index.php:

<?php
require_once XOOPS_ROOT_PATH . '/kernel/admin.php';
xoops_cp_header();
echo "<h1>Module Administration</h1>";
xoops_cp_footer();
?>

A:

  1. Set in xoopsversion.php:
<?php
$modversion['hasSearch'] = 1;
$modversion['search'] = 'search.php';
?>
  1. Create search.php:
<?php
function mymodule_search($queryArray, $andor, $limit, $offset) {
// Search implementation
$results = [];
return $results;
}
?>

A:

  1. 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']
];
?>
  1. Trigger notification in code:
<?php
$notification_handler = xoops_getHandler('notification');
$notification_handler->triggerEvent(
'item_published',
$item_id,
'Item published',
'description'
);
?>

A:

  1. Go to XOOPS Admin > Modules > Module Permissions
  2. Select the module
  3. Choose user/group and permission level
  4. Save

In code:

<?php
// Check if user can access module
if (!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');
}
?>

A: All in the main XOOPS database, prefixed with your table prefix (usually xoops_):

Okno terminala
# List all module tables
mysql> 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);
}
?>

A: Create an update script in your module:

modules/mymodule/update.php
<?php
require_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;
}
?>

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');
}
?>

A: Yes, declare in xoopsversion.php:

<?php
$modversion['dependencies'] = [
[
'dirname' => 'required_module',
'version_min' => '1.0',
'version_max' => 0, // 0 = unlimited
'order' => 1
]
];
?>

A: Check:

  1. xoopsversion.php syntax - Use PHP linter:
Okno terminala
php -l modules/mymodule/xoopsversion.php
  1. Database SQL file:
Okno terminala
# Check SQL syntax
grep -n "CREATE TABLE" modules/mymodule/sql/mysql.sql
  1. Language files:
Okno terminala
ls -la modules/mymodule/language/english/

See Module Installation Failures for detailed diagnostics.


A:

  1. Set hasMain = 1 in xoopsversion.php:
<?php
$modversion['hasMain'] = 1;
$modversion['main_file'] = 'index.php';
?>
  1. Create modules/mymodule/index.php:
<?php
require_once '../../mainfile.php';
include_once XOOPS_ROOT_PATH . '/header.php';
echo "Welcome to my module";
include_once XOOPS_ROOT_PATH . '/footer.php';
?>

A: Enable debugging to find the error:

<?php
// In mainfile.php
error_reporting(E_ALL);
ini_set('display_errors', '1');
define('XOOPS_DEBUG_LEVEL', 2);
?>

Check the error log:

Okno terminala
tail -100 /var/log/php/error.log
tail -100 /var/log/apache2/error.log

See White Screen of Death for solutions.


A:

  1. Check database queries - Use query logging
  2. 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
}
?>
  1. Optimize templates - Avoid loops in templates
  2. Enable PHP opcode cache - APCu, XDebug, etc.

See Performance FAQ for more details.


A: See:

  • Module Development Guide
  • Module Structure
  • Creating Your First Module

  • Module Installation Failures
  • Module Structure
  • Performance FAQ
  • Enable Debug Mode

#xoops #modules #faq #troubleshooting