Browse code

Add list page picker to booking list module

Benjamin Roth authored on08/09/2023 13:01:36
Showing4 changed files
... ...
@@ -12,7 +12,7 @@ use vonRotenberg\WeinanlieferungBundle\Controller\Frontend\Module\Weinanlieferun
12 12
 use vonRotenberg\WeinanlieferungBundle\Controller\Frontend\Module\WeinanlieferungSlotsListModuleController;
13 13
 
14 14
 $GLOBALS['TL_DCA']['tl_module']['palettes'][WeinanlieferungSlotsListModuleController::TYPE] = '{title_legend},name,headline,type;{wa_config_legend},vr_wa_standortId;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},cssID';
15
-$GLOBALS['TL_DCA']['tl_module']['palettes'][WeinanlieferungBookedListModuleController::TYPE] = '{title_legend},name,headline,type;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},cssID';
15
+$GLOBALS['TL_DCA']['tl_module']['palettes'][WeinanlieferungBookedListModuleController::TYPE] = '{title_legend},name,headline,type;{wa_config_legend},vr_wa_listPage;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},cssID';
16 16
 
17 17
 
18 18
 $GLOBALS['TL_DCA']['tl_module']['fields']['vr_wa_standortId'] = array(
... ...
@@ -23,3 +23,11 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['vr_wa_standortId'] = array(
23 23
     'sql'        => "blob NULL",
24 24
     'relation'   => array('type' => 'hasMany', 'load' => 'lazy')
25 25
 );
26
+$GLOBALS['TL_DCA']['tl_module']['fields']['vr_wa_listPage'] = array(
27
+    'exclude'                 => true,
28
+    'inputType'               => 'pageTree',
29
+    'foreignKey'              => 'tl_page.title',
30
+    'eval'                    => array('fieldType'=>'radio', 'tl_class'=>'clr'),
31
+    'sql'                     => "int(10) unsigned NOT NULL default 0",
32
+    'relation'                => array('type'=>'hasOne', 'load'=>'lazy')
33
+);
... ...
@@ -10,5 +10,7 @@
10 10
 
11 11
 $GLOBALS['TL_LANG']['tl_module']['vr_wa_standortId'][0] = 'Standort';
12 12
 $GLOBALS['TL_LANG']['tl_module']['vr_wa_standortId'][1] = 'Wählen Sie hier die Standorte aus, deren Zeitslots sie auflisten möchten.';
13
+$GLOBALS['TL_LANG']['tl_module']['vr_wa_listPage'][0] = 'Listenseite';
14
+$GLOBALS['TL_LANG']['tl_module']['vr_wa_listPage'][1] = 'Wählen Sie hier die Seite mit dem Weinanlieferung-Zeitslots Modul aus.';
13 15
 
14 16
 $GLOBALS['TL_LANG']['tl_module']['wa_config_legend'] = 'Weinanlieferung-Einstellungen';
... ...
@@ -82,9 +82,11 @@
82 82
                 <h6 class="placeholder-title">Sie haben noch keine Anlieferungszeiten reserviert</h6>
83 83
                 <div class="placeholder-subtitle">Sobald Sie Anlieferungszeiten reserviert haben, werden diese hier aufgelistet.</div>
84 84
                 <div class="placeholder-commands u-center">
85
-                    <div class="m-1">
86
-                        <a href="{{ insert_tag('link_url::2') }}" class="btn btn-info">Zur Reservierung</a>
87
-                    </div>
85
+                    {% if listPageUrl is defined %}
86
+                        <div class="m-1">
87
+                            <a href="{{ listPageUrl }}" class="btn btn-info">Zur Reservierung</a>
88
+                        </div>
89
+                    {% endif %}
88 90
                 </div>
89 91
             </div>
90 92
         {% endif %}
... ...
@@ -20,6 +20,7 @@ use Contao\CoreBundle\ServiceAnnotation\FrontendModule;
20 20
 use Contao\Date;
21 21
 use Contao\FrontendUser;
22 22
 use Contao\ModuleModel;
23
+use Contao\PageModel;
23 24
 use Contao\StringUtil;
24 25
 use Contao\System;
25 26
 use Contao\Template;
... ...
@@ -49,6 +50,10 @@ class WeinanlieferungBookedListModuleController extends AbstractFrontendModuleCo
49 50
     {
50 51
         $GLOBALS['TL_CSS']['vr_wa'] = 'bundles/vonrotenbergweinanlieferung/css/frontend.scss|static';
51 52
         $arrData = $template->getData();
53
+        if (($ListPage = PageModel::findById($model->vr_wa_listPage)) !== null)
54
+        {
55
+            $arrData['listPageUrl'] = $ListPage->getFrontendUrl();
56
+        }
52 57
 
53 58
         // Get bookings
54 59
         if (($bookings = WeinanlieferungReservationModel::findBy("uid",FrontendUser::getInstance()->id,['order' => "(SELECT tl_vr_wa_slot.time FROM tl_vr_wa_slot WHERE tl_vr_wa_slot.id=tl_vr_wa_reservation.pid) ASC"])) !== null)