Skip to content

Commit

Permalink
Update mod_jem to use the Joomla's layouts techniques #1813
Browse files Browse the repository at this point in the history
First module with layouts in the module, add example of table layout.
  • Loading branch information
mckillo committed Oct 25, 2024
1 parent a16c3c9 commit f1c4b80
Show file tree
Hide file tree
Showing 13 changed files with 600 additions and 139 deletions.
4 changes: 4 additions & 0 deletions modules/mod_jem/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ public static function getList(&$params)

$lists[$i]->eventid = $row->id;
$lists[$i]->link = Route::_(JemHelperRoute::getEventRoute($row->slug));
$lists[$i]->dates = $row->dates;
$lists[$i]->times = $row->times;
$lists[$i]->enddates = $row->enddates;
$lists[$i]->endtimes = $row->endtimes;
$lists[$i]->dateinfo = JemOutput::formatDateTime($row->dates, $row->times, $row->enddates, $row->endtimes,
$dateFormat, $timeFormat, $addSuffix);
$lists[$i]->text = $params->get('showtitloc', 0) ? $row->title : htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8');
Expand Down
10 changes: 4 additions & 6 deletions modules/mod_jem/mod_jem.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\Module\Menu\Site\Helper\MenuHelper;

// get helper
require_once __DIR__ . '/helper.php';

Expand All @@ -21,17 +24,12 @@
Factory::getApplication()->getLanguage()->load('com_jem', JPATH_SITE.'/components/com_jem');

$list = ModJemHelper::getList($params);

// check if any results returned
if (empty($list) && !$params->get('show_no_events')) {
return;
}

$mod_name = 'mod_jem';

// maybe a layout style provides a css file
JemHelper::loadModuleStyleSheet($mod_name);
// load icon font if needed
JemHelper::loadIconFont();

require(JemHelper::getModuleLayoutPath($mod_name));
require ModuleHelper::getLayoutPath('mod_jem', $params->get('layout', 'default'));
130 changes: 74 additions & 56 deletions modules/mod_jem/mod_jem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@
<folder>language</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/mod_jem.ini</language>
<language tag="en-GB">language/en-GB/mod_jem.sys.ini</language>
</languages>
<language tag="en-GB">language/en-GB/mod_jem.ini</language>
<language tag="en-GB">language/en-GB/mod_jem.sys.ini</language>
</languages>
<help key="Modules" />
<config>
<fields name="params">
<fieldset name="basic" addfieldpath="/administrator/components/com_jem/models/fields">
<field name="type" type="list"
default="0"
label="MOD_JEM_UPCOMING_OR_ARCHIVED"
description="MOD_JEM_UPCOMING_OR_ARCHIVED_DESC"
default="0"
label="MOD_JEM_UPCOMING_OR_ARCHIVED"
description="MOD_JEM_UPCOMING_OR_ARCHIVED_DESC"
>
<option value="0">MOD_JEM_UPCOMING_EVENTS</option>
<option value="1">MOD_JEM_UNFINISHED_EVENTS</option>
<option value="2">MOD_JEM_ARCHIVED_EVENTS</option>
</field>
<field name="count" type="text"
default="5"
label="MOD_JEM_EVENTS_IN_MODULE"
description="MOD_JEM_EVENTS_IN_MODULE_DESC"
default="5"
label="MOD_JEM_EVENTS_IN_MODULE"
description="MOD_JEM_EVENTS_IN_MODULE_DESC"
/>
<field name="show_no_events" type="radio"
default="1"
label="MOD_JEM_SHOW_NO_EVENTS"
description="MOD_JEM_SHOW_NO_EVENTS_DESC"
class="btn-group btn-group-yesno"
default="1"
label="MOD_JEM_SHOW_NO_EVENTS"
description="MOD_JEM_SHOW_NO_EVENTS_DESC"
class="btn-group btn-group-yesno"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
Expand All @@ -63,36 +63,36 @@
</field>

<field name="offset_hours" type="text"
default=""
label="MOD_JEM_OFFSET_HOURS"
description="MOD_JEM_OFFSET_HOURS_DESC"
default=""
label="MOD_JEM_OFFSET_HOURS"
description="MOD_JEM_OFFSET_HOURS_DESC"
/>
<field name="showtitloc" type="list"
default="1"
label="MOD_JEM_TITLE_OR_VENUE"
description="MOD_JEM_TITLE_OR_VENUE_DESC"
default="1"
label="MOD_JEM_TITLE_OR_VENUE"
description="MOD_JEM_TITLE_OR_VENUE_DESC"
>
<option value="0">MOD_JEM_VENUE</option>
<option value="1">MOD_JEM_TITLE</option>
</field>
<field name="cuttitle" type="text"
default="30"
label="MOD_JEM_MAX_TITLE_LENGTH"
description="MOD_JEM_MAX_TITLE_LENGTH_DESC"
default="30"
label="MOD_JEM_MAX_TITLE_LENGTH"
description="MOD_JEM_MAX_TITLE_LENGTH_DESC"
/>
<field name="linkloc" type="radio"
default="1"
label="MOD_JEM_LINK_TO_VENUE"
description="MOD_JEM_LINK_TO_VENUE_DESC"
class="btn-group btn-group-yesno"
default="1"
label="MOD_JEM_LINK_TO_VENUE"
description="MOD_JEM_LINK_TO_VENUE_DESC"
class="btn-group btn-group-yesno"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="linkdet" type="list"
default="1"
label="MOD_JEM_LINK_TO_EVENT"
description="MOD_JEM_LINK_TO_EVENT_DESC"
default="1"
label="MOD_JEM_LINK_TO_EVENT"
description="MOD_JEM_LINK_TO_EVENT_DESC"
>
<option value="0">JNO</option>
<option value="1">MOD_JEM_DATE</option>
Expand All @@ -108,49 +108,67 @@
<option value="0">JNO</option>
</field>
<field name="catid" type="categoryedit"
default=""
multiple="true"
removeroot="true"
label="MOD_JEM_CATEGORY_ID"
description="MOD_JEM_CATEGORY_ID_DESC"
default=""
multiple="true"
removeroot="true"
label="MOD_JEM_CATEGORY_ID"
description="MOD_JEM_CATEGORY_ID_DESC"
/>
<field name="venid" type="venueoptions"
default=""
multiple="true"
label="MOD_JEM_VENUE_ID"
description="MOD_JEM_VENUE_ID_DESC"
default=""
multiple="true"
label="MOD_JEM_VENUE_ID"
description="MOD_JEM_VENUE_ID_DESC"
/>
<field name="formatdate" type="text"
default="D, j. F Y"
label="MOD_JEM_DATE_FORMAT"
description="MOD_JEM_DATE_FORMAT_DESC"
default="D, j. F Y"
label="MOD_JEM_DATE_FORMAT"
description="MOD_JEM_DATE_FORMAT_DESC"
/>
<field name="formattime" type="text"
default=""
label="MOD_JEM_TIME_FORMAT"
description="MOD_JEM_TIME_FORMAT_DESC"
default=""
label="MOD_JEM_TIME_FORMAT"
description="MOD_JEM_TIME_FORMAT_DESC"
/>
<field name="moduleclass_sfx" type="text"
default=""
label="MOD_JEM_MODULE_CLASS_SUFFIX"
description="MOD_JEM_MODULE_CLASS_SUFFIX_DESC"
default=""
label="MOD_JEM_MODULE_CLASS_SUFFIX"
description="MOD_JEM_MODULE_CLASS_SUFFIX_DESC"
/>
</fieldset>

<fieldset name="advanced">
<field name="layout" type="modulelayout"
label="JFIELD_ALT_LAYOUT_LABEL"
class="form-select"
validate="moduleLayout"
/>
<field name="moduleclass_sfx" type="textarea"
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
rows="3"
validate="CssIdentifier"
/>
<field name="cache" type="list"
default="1"
label="MOD_JEM_CACHING"
description="MOD_JEM_CACHING_DESC"
label="MOD_JEM_CACHING"
description="MOD_JEM_CACHING_DESC"
default="1"
filter="integer"
validate="options"
>
<option value="1">MOD_JEM_USE_GLOBAL</option>
<option value="0">MOD_JEM_NO_CACHING</option>
<option value="1">JGLOBAL_USE_GLOBAL</option>
<option value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
</field>
<field name="cache_time" type="text"
default="900"
label="MOD_JEM_CACHE_TIME"
description="MOD_JEM_CACHE_TIME_DESC"
<field name="cache_time" type="number"
label="MOD_JEM_CACHE_TIME"
description="MOD_JEM_CACHE_TIME_DESC"
default="900"
filter="integer"
/>
<field name="cachemode" type="hidden"
default="static"
>
<option value="static"></option>
</field>
</fieldset>
</fields>
</config>
Expand Down
File renamed without changes.
56 changes: 56 additions & 0 deletions modules/mod_jem/tmpl/mod_jem_table-advanced.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* @package JEM
* @subpackage JEM Latest Events Basic Module
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/

.jemmodulebasic i {
padding-right:10px;
}

#jemmodulebasic-tableadvanced table {
width: 100%;
border-collapse: collapse;
font-family: Arial, sans-serif;
font-size: 14px;
background-color: #f9f9f9;
margin: 20px 0;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#jemmodulebasic-tableadvanced tr:nth-child(even) {
background-color: #f1f1f1;
}

#jemmodulebasic-tableadvanced tr:hover {
background-color: #eaeaea;
}

#jemmodulebasic-tableadvanced th,
#jemmodulebasic-tableadvanced td {
padding: 12px 15px;
text-align: left;
border: 1px solid #ddd;
text-align: center;
}

#jemmodulebasic-tableadvanced th {
background-color: #4CAF50;
color: white;
font-weight: bold;
}

#jemmodulebasic-tableadvanced td {
color: #333;
}

#jemmodulebasic-tableadvanced caption {
caption-side: top;
font-size: 18px;
font-weight: bold;
padding: 10px;
color: #555;
}

52 changes: 52 additions & 0 deletions modules/mod_jem/tmpl/mod_jem_table-style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @package JEM
* @subpackage JEM Latest Events Basic Module
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/


#jemmodulebasic-tablestyle table {
width: 100%;
border-collapse: collapse;
font-family: Arial, sans-serif;
font-size: 14px;
background-color: #f9f9f9;
margin: 20px 0;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#jemmodulebasic-tablestyle tr:nth-child(even) {
background-color: #f1f1f1;
}

#jemmodulebasic-tablestyle tr:hover {
background-color: #eaeaea;
}

#jemmodulebasic-tablestyle th,
#jemmodulebasic-tablestyle td {
padding: 12px 15px;
text-align: left;
border: 1px solid #ddd;
}

#jemmodulebasic-tablestyle th {
background-color: #4CAF50;
color: white;
font-weight: bold;
}

#jemmodulebasic-tablestyle td {
color: #333;
}

#jemmodulebasic-tablestyle caption {
caption-side: top;
font-size: 18px;
font-weight: bold;
padding: 10px;
color: #555;
}

33 changes: 33 additions & 0 deletions modules/mod_jem/tmpl/mod_jem_table.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @package JEM
* @subpackage JEM Latest Events Basic Module
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/


#jemmodulebasic-table table {

}

#jemmodulebasic-table tr:nth-child(even) {

}

#jemmodulebasic-table tr:hover {
background-color: #eaeaea;
}

#jemmodulebasic-table th {

}

#jemmodulebasic-table td {
padding: 0 10px;
}

#jemmodulebasic-table caption {

}

Loading

0 comments on commit f1c4b80

Please sign in to comment.