Browse code

Add teaser text and image to page item instead of looking up the teaser in first article of page

Benjamin Roth authored on24/08/2016 14:38:37
Showing7 changed files
1 1
deleted file mode 100644
... ...
@@ -1,39 +0,0 @@
1
-<?php
2
-
3
-/**
4
- * Pagelist for Contao
5
- *
6
- * Copyright (c) 2015 Benjamin Roth
7
- *
8
- * @license LGPL-3.0+
9
- */
10
-
11
-/**
12
- * Palettes
13
- */
14
-$str_replace = ',teaser,teaserSRC,teaserSize';
15
-$GLOBALS['TL_DCA']['tl_article']['palettes']['default'] = str_replace(array(',teaser,',',teaser;'), array($str_replace.',',$str_replace.';'),$GLOBALS['TL_DCA']['tl_article']['palettes']['default']);
16
-
17
-
18
-/**
19
- * Fields
20
- */
21
-$GLOBALS['TL_DCA']['tl_article']['fields']['teaserSRC'] = array
22
-(
23
-    'label'                   => &$GLOBALS['TL_LANG']['tl_article']['teaserSRC'],
24
-    'exclude'                 => true,
25
-    'inputType'               => 'fileTree',
26
-    'eval'                    => array('fieldType'=>'checkbox', 'multiple'=>false, 'files'=>true, 'filesOnly'=>true, 'extensions'=>'jpg,gif,png,jpeg'),
27
-    'sql'                     => 'binary(16) NULL'
28
-);
29
-
30
-$GLOBALS['TL_DCA']['tl_article']['fields']['teaserSize'] = array
31
-(
32
-    'label'                   => &$GLOBALS['TL_LANG']['tl_article']['teaserSize'],
33
-    'exclude'                 => true,
34
-    'inputType'               => 'imageSize',
35
-    'options'                 => System::getImageSizes(),
36
-    'reference'               => &$GLOBALS['TL_LANG']['MSC'],
37
-    'eval'                    => array('rgxp'=>'natural', 'includeBlankOption'=>true, 'nospace'=>true, 'helpwizard'=>true),
38
-    'sql'                     => "varchar(64) NOT NULL default ''"
39
-);
40 0
\ No newline at end of file
41 1
new file mode 100644
... ...
@@ -0,0 +1,57 @@
1
+<?php
2
+
3
+/**
4
+ * Pagelist for Contao
5
+ *
6
+ * Copyright (c) 2015 Benjamin Roth
7
+ *
8
+ * @license LGPL-3.0+
9
+ */
10
+
11
+/**
12
+ * Palettes
13
+ */
14
+$GLOBALS['TL_DCA']['tl_page']['palettes']['regular'] = str_replace('{meta_legend}', '{teaser_legend},teaserCssID,teaser,teaserSRC,teaserSize;{meta_legend}',$GLOBALS['TL_DCA']['tl_page']['palettes']['regular']);
15
+
16
+
17
+/**
18
+ * Fields
19
+ */
20
+$GLOBALS['TL_DCA']['tl_page']['fields']['teaserSRC'] = array
21
+(
22
+    'label'                   => &$GLOBALS['TL_LANG']['tl_page']['teaserSRC'],
23
+    'exclude'                 => true,
24
+    'inputType'               => 'fileTree',
25
+    'eval'                    => array('fieldType'=>'checkbox', 'multiple'=>false, 'files'=>true, 'filesOnly'=>true, 'extensions'=>'jpg,gif,png,jpeg'),
26
+    'sql'                     => 'binary(16) NULL'
27
+);
28
+
29
+$GLOBALS['TL_DCA']['tl_page']['fields']['teaserSize'] = array
30
+(
31
+    'label'                   => &$GLOBALS['TL_LANG']['tl_page']['teaserSize'],
32
+    'exclude'                 => true,
33
+    'inputType'               => 'imageSize',
34
+    'options'                 => System::getImageSizes(),
35
+    'reference'               => &$GLOBALS['TL_LANG']['MSC'],
36
+    'eval'                    => array('rgxp'=>'natural', 'includeBlankOption'=>true, 'nospace'=>true, 'helpwizard'=>true),
37
+    'sql'                     => "varchar(64) NOT NULL default ''"
38
+);
39
+
40
+$GLOBALS['TL_DCA']['tl_page']['fields']['teaserCssID'] = array
41
+(
42
+  'label'                   => &$GLOBALS['TL_LANG']['tl_page']['teaserCssID'],
43
+  'exclude'                 => true,
44
+  'inputType'               => 'text',
45
+  'eval'                    => array('multiple'=>true, 'size'=>2),
46
+  'sql'                     => "varchar(255) NOT NULL default ''"
47
+);
48
+
49
+$GLOBALS['TL_DCA']['tl_page']['fields']['teaser'] = array
50
+(
51
+  'label'                   => &$GLOBALS['TL_LANG']['tl_page']['teaser'],
52
+  'exclude'                 => true,
53
+  'inputType'               => 'textarea',
54
+  'search'                  => true,
55
+  'eval'                    => array('rte'=>'tinyMCE', 'tl_class'=>'clr'),
56
+  'sql'                     => "text NULL"
57
+);
0 58
\ No newline at end of file
1 59
deleted file mode 100644
... ...
@@ -1,17 +0,0 @@
1
-<?php
2
-
3
-/**
4
- * Pagelist for Contao
5
- *
6
- * Copyright (c) 2015 Benjamin Roth
7
- *
8
- * @license LGPL-3.0+
9
- */
10
-
11
-/**
12
- * Fields
13
- */
14
-$GLOBALS['TL_LANG']['tl_article']['teaserSRC'][0] = 'Teaserbild';
15
-$GLOBALS['TL_LANG']['tl_article']['teaserSRC'][1] = 'Bitte wählen Sie eine Bilddatei aus der Dateiübersicht.';
16
-$GLOBALS['TL_LANG']['tl_article']['teaserSize'][0] = 'Bildgröße';
17
-$GLOBALS['TL_LANG']['tl_article']['teaserSize'][1] = 'Hier können Sie Abmessungen des Bildes und den Skalierungsmodus festlegen.';
18 0
new file mode 100644
... ...
@@ -0,0 +1,27 @@
1
+<?php
2
+
3
+/**
4
+ * Pagelist for Contao
5
+ *
6
+ * Copyright (c) 2015 Benjamin Roth
7
+ *
8
+ * @license LGPL-3.0+
9
+ */
10
+
11
+/**
12
+ * Fields
13
+ */
14
+$GLOBALS['TL_LANG']['tl_page']['teaserSRC'][0] = 'Teaserbild';
15
+$GLOBALS['TL_LANG']['tl_page']['teaserSRC'][1] = 'Bitte wählen Sie eine Bilddatei aus der Dateiübersicht.';
16
+$GLOBALS['TL_LANG']['tl_page']['teaserSize'][0] = 'Bildgröße';
17
+$GLOBALS['TL_LANG']['tl_page']['teaserSize'][1] = 'Hier können Sie Abmessungen des Bildes und den Skalierungsmodus festlegen.';
18
+$GLOBALS['TL_LANG']['tl_page']['teaserCssID'][0] = 'Teaser-CSS-ID/Klasse';
19
+$GLOBALS['TL_LANG']['tl_page']['teaserCssID'][1] = 'Hier können Sie eine ID und beliebig viele Klassen für das Teaser-Element eingeben.';
20
+$GLOBALS['TL_LANG']['tl_page']['teaser'][0] = 'Artikelteaser';
21
+$GLOBALS['TL_LANG']['tl_page']['teaser'][1] = 'Der Teasertext kann auch mit dem Inhaltselement &quot;Artikelteaser&quot; dargestellt werden.';
22
+
23
+
24
+/**
25
+ * Legends
26
+ */
27
+$GLOBALS['TL_LANG']['tl_page']['teaser_legend'] = 'Artikelteaser';
0 28
deleted file mode 100644
... ...
@@ -1,17 +0,0 @@
1
-<?php
2
-
3
-/**
4
- * Pagelist for Contao
5
- *
6
- * Copyright (c) 2015 Benjamin Roth
7
- *
8
- * @license LGPL-3.0+
9
- */
10
-
11
-/**
12
- * Fields
13
- */
14
-$GLOBALS['TL_LANG']['tl_article']['teaserSRC'][0] = 'Teaser image';
15
-$GLOBALS['TL_LANG']['tl_article']['teaserSRC'][1] = 'Please choose an image file from the files directory.';
16
-$GLOBALS['TL_LANG']['tl_article']['teaserSize'][0] = 'Image size';
17
-$GLOBALS['TL_LANG']['tl_article']['teaserSize'][1] = 'Here you can set the image dimensions and the resize mode.';
18 0
new file mode 100644
... ...
@@ -0,0 +1,27 @@
1
+<?php
2
+
3
+/**
4
+ * Pagelist for Contao
5
+ *
6
+ * Copyright (c) 2015 Benjamin Roth
7
+ *
8
+ * @license LGPL-3.0+
9
+ */
10
+
11
+/**
12
+ * Fields
13
+ */
14
+$GLOBALS['TL_LANG']['tl_page']['teaserSRC'][0] = 'Teaser image';
15
+$GLOBALS['TL_LANG']['tl_page']['teaserSRC'][1] = 'Please choose an image file from the files directory.';
16
+$GLOBALS['TL_LANG']['tl_page']['teaserSize'][0] = 'Image size';
17
+$GLOBALS['TL_LANG']['tl_page']['teaserSize'][1] = 'Here you can set the image dimensions and the resize mode.';
18
+$GLOBALS['TL_LANG']['tl_page']['teaserCssID'][0] = 'Teaser CSS ID/class';
19
+$GLOBALS['TL_LANG']['tl_page']['teaserCssID'][1] = 'Here you can set an ID and one or more classes for the teaser element.';
20
+$GLOBALS['TL_LANG']['tl_page']['teaser'][0] = 'Article teaser';
21
+$GLOBALS['TL_LANG']['tl_page']['teaser'][1] = 'The article teaser can also be displayed with the content element &quot;article teaser&quot;.';
22
+
23
+
24
+/**
25
+ * Legends
26
+ */
27
+$GLOBALS['TL_LANG']['tl_page']['teaser_legend'] = 'Article teaser';
... ...
@@ -185,25 +185,14 @@ class ModulePagelist extends Module
185 185
 				// Get href
186 186
 				$href = $this->generateFrontendUrl($objSubpages->row());
187 187
 				
188
-				$objArticle = $this->Database->prepare("SELECT a.id AS aid, a.title AS title, a.alias AS aalias, a.teaser AS teaser, a.teaserSRC AS teaserSRC, a.teaserSize AS teaserSize, a.inColumn AS inColumn, a.teaserCssID AS teaserCssID FROM tl_article a WHERE a.pid=? AND inColumn = 'main' ORDER BY sorting")
189
-				->limit(1)
190
-				->execute($objSubpages->id);
191
-
192
-				if ($objArticle->numRows < 1)
193
-				{
194
-					continue;
195
-				}
196
-				
197
-				$objContent = $this->Database->execute("SELECT count(id) as `count` FROM tl_content WHERE pid = '".$objArticle->aid."'");
198
-				
199 188
 				$row = $objSubpages->row();
200 189
 
201 190
 				// Add an image
202
-				if ($this->showTeaserImg && $objArticle->teaserSRC != '')
191
+				if ($this->showTeaserImg && $objSubpages->teaserSRC != '')
203 192
 				{
204 193
 					$arrData = array();
205 194
 					$objClass = new \stdClass();
206
-					$objModel = \FilesModel::findByUuid($objArticle->teaserSRC);
195
+					$objModel = \FilesModel::findByUuid($objSubpages->teaserSRC);
207 196
 
208 197
 					// Override the default image size
209 198
 					if ($this->imgSize != '')
... ...
@@ -215,7 +204,7 @@ class ModulePagelist extends Module
215 204
 							$arrData['size'] = $this->imgSize;
216 205
 						}
217 206
 					} else {
218
-						$arrData['size'] = $objArticle->teaserSize;
207
+						$arrData['size'] = $objSubpages->teaserSize;
219 208
 					}
220 209
 
221 210
 					if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path))
... ...
@@ -230,18 +219,15 @@ class ModulePagelist extends Module
230 219
 
231 220
 				$row['isActive'] = ($objPage->id == $objSubpages->id ? true : false);
232 221
 				$row['subitems'] = (bool) $subitems;
233
-				list($row['cssId'], $row['class']) = (deserialize($objArticle->teaserCssID));
222
+				list($row['cssId'], $row['class']) = (deserialize($objSubpages->teaserCssID));
234 223
 				$row['title'] = $objSubpages->title;
235 224
 				$row['pageTitle'] = $objSubpages->pageTitle;
236 225
 				$row['href'] = $href;
237 226
 
238
-				$row['headline'] = $objArticle->title;
239
-				$row['text'] = $objArticle->teaser;
240
-				if ($objContent->count > 0)
241
-				{
242
-					$row['readMore'] = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objArticle->title));
243
-					$row['more'] = $GLOBALS['TL_LANG']['MSC']['more'];
244
-				}
227
+				$row['headline'] = $objSubpages->title;
228
+				$row['text'] = $objSubpages->teaser;
229
+        $row['readMore'] = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objSubpages->title));
230
+        $row['more'] = $GLOBALS['TL_LANG']['MSC']['more'];
245 231
 
246 232
 				$items[] = $row;
247 233
 			}