Skip to content

Commit ebf1746

Browse files
committed
Update mod_jem to use the Joomla's layouts techniques #1813
First module with layouts in the module, add example of table layout.
1 parent a16c3c9 commit ebf1746

File tree

8 files changed

+301
-139
lines changed

8 files changed

+301
-139
lines changed

modules/mod_jem/mod_jem.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
defined('_JEXEC') or die;
1111

1212
use Joomla\CMS\Factory;
13+
use Joomla\CMS\Helper\ModuleHelper;
14+
use Joomla\Module\Menu\Site\Helper\MenuHelper;
15+
1316
// get helper
1417
require_once __DIR__ . '/helper.php';
1518

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

2326
$list = ModJemHelper::getList($params);
24-
2527
// check if any results returned
2628
if (empty($list) && !$params->get('show_no_events')) {
2729
return;
2830
}
2931

30-
$mod_name = 'mod_jem';
31-
32-
// maybe a layout style provides a css file
33-
JemHelper::loadModuleStyleSheet($mod_name);
3432
// load icon font if needed
3533
JemHelper::loadIconFont();
3634

37-
require(JemHelper::getModuleLayoutPath($mod_name));
35+
require ModuleHelper::getLayoutPath('mod_jem', $params->get('layout', 'default'));

modules/mod_jem/mod_jem.xml

Lines changed: 74 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,32 @@
2222
<folder>language</folder>
2323
</files>
2424
<languages>
25-
<language tag="en-GB">language/en-GB/mod_jem.ini</language>
26-
<language tag="en-GB">language/en-GB/mod_jem.sys.ini</language>
27-
</languages>
25+
<language tag="en-GB">language/en-GB/mod_jem.ini</language>
26+
<language tag="en-GB">language/en-GB/mod_jem.sys.ini</language>
27+
</languages>
2828
<help key="Modules" />
2929
<config>
3030
<fields name="params">
3131
<fieldset name="basic" addfieldpath="/administrator/components/com_jem/models/fields">
3232
<field name="type" type="list"
33-
default="0"
34-
label="MOD_JEM_UPCOMING_OR_ARCHIVED"
35-
description="MOD_JEM_UPCOMING_OR_ARCHIVED_DESC"
33+
default="0"
34+
label="MOD_JEM_UPCOMING_OR_ARCHIVED"
35+
description="MOD_JEM_UPCOMING_OR_ARCHIVED_DESC"
3636
>
3737
<option value="0">MOD_JEM_UPCOMING_EVENTS</option>
3838
<option value="1">MOD_JEM_UNFINISHED_EVENTS</option>
3939
<option value="2">MOD_JEM_ARCHIVED_EVENTS</option>
4040
</field>
4141
<field name="count" type="text"
42-
default="5"
43-
label="MOD_JEM_EVENTS_IN_MODULE"
44-
description="MOD_JEM_EVENTS_IN_MODULE_DESC"
42+
default="5"
43+
label="MOD_JEM_EVENTS_IN_MODULE"
44+
description="MOD_JEM_EVENTS_IN_MODULE_DESC"
4545
/>
4646
<field name="show_no_events" type="radio"
47-
default="1"
48-
label="MOD_JEM_SHOW_NO_EVENTS"
49-
description="MOD_JEM_SHOW_NO_EVENTS_DESC"
50-
class="btn-group btn-group-yesno"
47+
default="1"
48+
label="MOD_JEM_SHOW_NO_EVENTS"
49+
description="MOD_JEM_SHOW_NO_EVENTS_DESC"
50+
class="btn-group btn-group-yesno"
5151
>
5252
<option value="1">JYES</option>
5353
<option value="0">JNO</option>
@@ -63,36 +63,36 @@
6363
</field>
6464

6565
<field name="offset_hours" type="text"
66-
default=""
67-
label="MOD_JEM_OFFSET_HOURS"
68-
description="MOD_JEM_OFFSET_HOURS_DESC"
66+
default=""
67+
label="MOD_JEM_OFFSET_HOURS"
68+
description="MOD_JEM_OFFSET_HOURS_DESC"
6969
/>
7070
<field name="showtitloc" type="list"
71-
default="1"
72-
label="MOD_JEM_TITLE_OR_VENUE"
73-
description="MOD_JEM_TITLE_OR_VENUE_DESC"
71+
default="1"
72+
label="MOD_JEM_TITLE_OR_VENUE"
73+
description="MOD_JEM_TITLE_OR_VENUE_DESC"
7474
>
7575
<option value="0">MOD_JEM_VENUE</option>
7676
<option value="1">MOD_JEM_TITLE</option>
7777
</field>
7878
<field name="cuttitle" type="text"
79-
default="30"
80-
label="MOD_JEM_MAX_TITLE_LENGTH"
81-
description="MOD_JEM_MAX_TITLE_LENGTH_DESC"
79+
default="30"
80+
label="MOD_JEM_MAX_TITLE_LENGTH"
81+
description="MOD_JEM_MAX_TITLE_LENGTH_DESC"
8282
/>
8383
<field name="linkloc" type="radio"
84-
default="1"
85-
label="MOD_JEM_LINK_TO_VENUE"
86-
description="MOD_JEM_LINK_TO_VENUE_DESC"
87-
class="btn-group btn-group-yesno"
84+
default="1"
85+
label="MOD_JEM_LINK_TO_VENUE"
86+
description="MOD_JEM_LINK_TO_VENUE_DESC"
87+
class="btn-group btn-group-yesno"
8888
>
8989
<option value="1">JYES</option>
9090
<option value="0">JNO</option>
9191
</field>
9292
<field name="linkdet" type="list"
93-
default="1"
94-
label="MOD_JEM_LINK_TO_EVENT"
95-
description="MOD_JEM_LINK_TO_EVENT_DESC"
93+
default="1"
94+
label="MOD_JEM_LINK_TO_EVENT"
95+
description="MOD_JEM_LINK_TO_EVENT_DESC"
9696
>
9797
<option value="0">JNO</option>
9898
<option value="1">MOD_JEM_DATE</option>
@@ -108,49 +108,67 @@
108108
<option value="0">JNO</option>
109109
</field>
110110
<field name="catid" type="categoryedit"
111-
default=""
112-
multiple="true"
113-
removeroot="true"
114-
label="MOD_JEM_CATEGORY_ID"
115-
description="MOD_JEM_CATEGORY_ID_DESC"
111+
default=""
112+
multiple="true"
113+
removeroot="true"
114+
label="MOD_JEM_CATEGORY_ID"
115+
description="MOD_JEM_CATEGORY_ID_DESC"
116116
/>
117117
<field name="venid" type="venueoptions"
118-
default=""
119-
multiple="true"
120-
label="MOD_JEM_VENUE_ID"
121-
description="MOD_JEM_VENUE_ID_DESC"
118+
default=""
119+
multiple="true"
120+
label="MOD_JEM_VENUE_ID"
121+
description="MOD_JEM_VENUE_ID_DESC"
122122
/>
123123
<field name="formatdate" type="text"
124-
default="D, j. F Y"
125-
label="MOD_JEM_DATE_FORMAT"
126-
description="MOD_JEM_DATE_FORMAT_DESC"
124+
default="D, j. F Y"
125+
label="MOD_JEM_DATE_FORMAT"
126+
description="MOD_JEM_DATE_FORMAT_DESC"
127127
/>
128128
<field name="formattime" type="text"
129-
default=""
130-
label="MOD_JEM_TIME_FORMAT"
131-
description="MOD_JEM_TIME_FORMAT_DESC"
129+
default=""
130+
label="MOD_JEM_TIME_FORMAT"
131+
description="MOD_JEM_TIME_FORMAT_DESC"
132132
/>
133133
<field name="moduleclass_sfx" type="text"
134-
default=""
135-
label="MOD_JEM_MODULE_CLASS_SUFFIX"
136-
description="MOD_JEM_MODULE_CLASS_SUFFIX_DESC"
134+
default=""
135+
label="MOD_JEM_MODULE_CLASS_SUFFIX"
136+
description="MOD_JEM_MODULE_CLASS_SUFFIX_DESC"
137137
/>
138138
</fieldset>
139139

140140
<fieldset name="advanced">
141+
<field name="layout" type="modulelayout"
142+
label="JFIELD_ALT_LAYOUT_LABEL"
143+
class="form-select"
144+
validate="moduleLayout"
145+
/>
146+
<field name="moduleclass_sfx" type="textarea"
147+
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
148+
rows="3"
149+
validate="CssIdentifier"
150+
/>
141151
<field name="cache" type="list"
142-
default="1"
143-
label="MOD_JEM_CACHING"
144-
description="MOD_JEM_CACHING_DESC"
152+
label="MOD_JEM_CACHING"
153+
description="MOD_JEM_CACHING_DESC"
154+
default="1"
155+
filter="integer"
156+
validate="options"
145157
>
146-
<option value="1">MOD_JEM_USE_GLOBAL</option>
147-
<option value="0">MOD_JEM_NO_CACHING</option>
158+
<option value="1">JGLOBAL_USE_GLOBAL</option>
159+
<option value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
148160
</field>
149-
<field name="cache_time" type="text"
150-
default="900"
151-
label="MOD_JEM_CACHE_TIME"
152-
description="MOD_JEM_CACHE_TIME_DESC"
161+
<field name="cache_time" type="number"
162+
label="MOD_JEM_CACHE_TIME"
163+
description="MOD_JEM_CACHE_TIME_DESC"
164+
default="900"
165+
filter="integer"
153166
/>
167+
<field name="cachemode" type="hidden"
168+
default="static"
169+
>
170+
<option value="static"></option>
171+
</field>
154172
</fieldset>
155173
</fields>
156174
</config>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* @package JEM
3+
* @subpackage JEM Latest Events Basic Module
4+
* @copyright (C) 2013-2024 joomlaeventmanager.net
5+
* @copyright (C) 2005-2009 Christoph Lukes
6+
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
7+
*/
8+
9+
10+
#jemmodulebasic table {
11+
width: 100%;
12+
border-collapse: collapse;
13+
font-family: Arial, sans-serif;
14+
font-size: 14px;
15+
background-color: #f9f9f9;
16+
margin: 20px 0;
17+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
18+
}
19+
20+
#jemmodulebasic tr:nth-child(even) {
21+
background-color: #f1f1f1;
22+
}
23+
24+
#jemmodulebasic tr:hover {
25+
background-color: #eaeaea;
26+
}
27+
28+
#jemmodulebasic th,
29+
#jemmodulebasic td {
30+
padding: 12px 15px;
31+
text-align: left;
32+
border: 1px solid #ddd;
33+
}
34+
35+
#jemmodulebasic th {
36+
background-color: #4CAF50;
37+
color: white;
38+
font-weight: bold;
39+
}
40+
41+
#jemmodulebasic td {
42+
color: #333;
43+
}
44+
45+
#jemmodulebasic caption {
46+
caption-side: top;
47+
font-size: 18px;
48+
font-weight: bold;
49+
padding: 10px;
50+
color: #555;
51+
}
52+

modules/mod_jem/tmpl/responsive.php

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
/**
3+
* @package JEM
4+
* @subpackage JEM Module
5+
* @copyright (C) 2013-2024 joomlaeventmanager.net
6+
* @copyright (C) 2005-2009 Christoph Lukes
7+
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
8+
*/
9+
10+
defined('_JEXEC') or die;
11+
12+
use Joomla\CMS\HTML\HTMLHelper;
13+
use Joomla\CMS\Language\Text;
14+
use Joomla\CMS\Factory;
15+
use Joomla\CMS\Uri\Uri;
16+
17+
$app = Factory::getApplication();
18+
$document = $app->getDocument();
19+
$module_name = 'mod_jem';
20+
21+
22+
$uri = Uri::getInstance();
23+
$css_path = JPATH_THEMES . '/' . $document->template . '/css/' . $module_name;
24+
if(file_exists($css_path . '/' . $module_name . '.css')) {
25+
unset($document->_styleSheets[$uri->base(true) . '/modules/mod_jem_/tmpl/mod_jem.css']);
26+
$document->addStylesheet($uri->base(true) . '/templates/' . $document->template . '/css/' . $module_name . '/' . $module_name . '.css');
27+
} else {
28+
$document->addStyleSheet($uri->base(true) . '/modules/mod_jem/tmpl/mod_jem_responsive.css');
29+
}
30+
31+
$highlight_featured = $params->get('highlight_featured');
32+
$showtitloc = $params->get('showtitloc');
33+
$linkloc = $params->get('linkloc');
34+
$linkdet = $params->get('linkdet');
35+
$showiconcountry = $params->get('showiconcountry');
36+
$settings = JemHelper::config();
37+
38+
HTMLHelper::_('stylesheet', 'modules/mod_jem/tmpl/default.css');
39+
?>
40+
41+
<div class="jemmodulebasic<?php echo $params->get('moduleclass_sfx')?>" id="jemmodulebasic">
42+
<?php if (count($list)): ?>
43+
<ul>
44+
<?php foreach ($list as $item) : ?>
45+
<li>
46+
<i class="far fa-calendar-alt"></i>
47+
<?php if($highlight_featured && $item->featured): ?>
48+
<span class="event-title highlight_featured">
49+
<?php else : ?>
50+
<span class="event-title">
51+
<?php endif; ?>
52+
<?php if (($showiconcountry == 1) && !empty($item->country)) : ?>
53+
<?php $flagpath = $settings->flagicons_path . (str_ends_with($settings->flagicons_path, '/')?'':'/');
54+
$flagext = substr($flagpath, strrpos($flagpath,"-")+1,-1) ;
55+
$flagfile = Uri::getInstance()->base() . $flagpath . strtolower($item->country) . '.' . $flagext;
56+
echo '<img src="' . $flagfile . '" alt="' . $item->country . ' ' , Text::_('MOD_JEM_SHOW_FLAG_ICON') . '">' ?>
57+
<?php endif; ?>
58+
<?php if ($showtitloc == 0 && $linkloc == 1) : ?>
59+
<a href="<?php echo $item->venueurl; ?>">
60+
<?php echo $item->text; ?>
61+
</a>
62+
<?php elseif ($showtitloc == 1 && $linkdet == 2) : ?>
63+
<a href="<?php echo $item->link; ?>" title="<?php echo strip_tags($item->text); ?>">
64+
<?php echo $item->text; ?>
65+
</a>
66+
<?php else :
67+
echo $item->text;
68+
endif; ?>
69+
</span>
70+
<br />
71+
<?php if($highlight_featured && $item->featured): ?>
72+
<span class="event-title highlight_featured">
73+
<?php else : ?>
74+
<span class="event-title">
75+
<?php endif; ?>
76+
<?php if ($linkdet == 1) : ?>
77+
<a href="<?php echo $item->link; ?>" title="<?php echo strip_tags($item->dateinfo); ?>">
78+
<?php echo $item->dateinfo; ?>
79+
</a>
80+
<?php else :
81+
echo $item->dateinfo;
82+
endif; ?>
83+
</span>
84+
</li>
85+
<?php endforeach; ?>
86+
</ul>
87+
<?php else : ?>
88+
<?php echo Text::_('COM_JEM_NO_EVENTS'); ?>
89+
<?php endif; ?>
90+
</div>

0 commit comments

Comments
 (0)