Creating a system within Joomla! to sort people by a number (like an employee ID, priority number, etc.) requires an understanding of Joomla!’s extensions and possibly some custom development, especially if you want functionality beyond basic article ordering. Here's how you could approach this by creating a simple Joomla! module or using custom fields with articles.
Option 1: Using Custom Fields with Articles
Step 1: Create a Custom Field
- Navigate to
Content > Fields and click on New to create a new field.
- Select the field type—
Number would be appropriate for sorting people by a numerical value.
- Fill in the title (e.g., "Employee ID") and other necessary details, then save.
Step 2: Assign the Custom Field to Articles
- When creating or editing an article (presumably representing a person), fill in the "Employee ID" field with the appropriate number.
Step 3: Modify Your Article Menu Item
- Go to
Menus > Your Menu and click on the menu item displaying the articles.
- Under
Blog Layout (or the similar layout options, depending on your Joomla! version), find the Article Order dropdown.
- Select
Ordering ascending or Ordering descending if you want to use the core ordering feature. Note: Custom field ordering directly via the menu item isn't a Joomla! core feature as of my last update.
Display With a Custom Module or Override for Advanced Sorting:
- You might need a custom module or a template override that queries articles and sorts them by the custom field value for direct sorting by the custom field number. This involves custom programming.
Option 2: Creating a Simple Joomla! Module for Custom Sorting (Basic PHP Knowledge Required)
This simplified example will guide you through creating a module that retrieves and sorts articles (representing people) by a custom field (e.g., "Employee ID").
Basic Module Files:
- mod_people_sorter.xml – Module descriptor file.
- mod_people_sorter.php – Main module file to process logic.
- tmpl/default.php – Default layout file.
mod_people_sorter.xml
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.9" client="site" method="upgrade">
<name>People Sorter</name>
<author>Your Name</author>
<version>1.0</version>
<description>Sorts people by number.</description>
<files>
<filename>mod_people_sorter.php</filename>
<filename>index.html</filename>
<folder>tmpl</folder>
</files>
</extension>
mod_people_sorter.php
<?php
defined('_JEXEC') or die;
// Load the model to interact with articles (assuming you want to fetch them)
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_content/models', 'ContentModel');
$model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
$model->setState('list.ordering', 'a.custom_field_value'); // Assuming `custom_field_value` is what you're sorting by
$model->setState('list.direction', 'ASC'); // or 'DESC' for descending
$articles = $model->getItems();
require JModuleHelper::getLayoutPath('mod_people_sorter');
tmpl/default.php
<?php defined('_JEXEC') or die; ?>
<div class="people-sorter">
<?php if (!empty($articles)): ?>
<ul>
<?php foreach ($articles as $article): ?>
<li><?php echo htmlspecialchars($article->title); ?> - <?php echo $article->custom_field_value; ?></li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p>No people found.</p>
<?php endif; ?>
</div>
This is a very basic example and doesn't account for grabbing the custom field directly. You would need to adjust your query to retrieve and sort by the appropriate custom field associated with each article. Joomla! does not directly support sorting articles in the menu item by custom field values without additional extensions or custom development.
For advanced functionality and dynamic sorting, consider leveraging Joomla!'s extension directory to find an extension that comes close to your requirements or developing a more sophisticated custom component or module.