@@ -49,6 +49,7 @@ public function getDocs($tvlist = '')
4949 public function _render ($ tpl = '' )
5050 {
5151 $ out = '' ;
52+ $ separator = $ this ->getCFGDef ('outputSeparator ' , '' );
5253 if ($ tpl == '' ) {
5354 $ tpl = $ this ->getCFGDef ('tpl ' , '' );
5455 }
@@ -127,6 +128,9 @@ public function _render($tpl = '')
127128 "item[ " . $ i . "] " ); // [+item[x]+] – individual placeholder for each iteration documents on this page
128129 }
129130 $ out .= $ tmp ;
131+ if (next ($ this ->_docs ) !== false ) {
132+ $ out .= $ separator ;
133+ }
130134 $ i ++;
131135 }
132136 }
@@ -208,7 +212,15 @@ protected function getDocList()
208212 $ out = array ();
209213 $ sanitarInIDs = $ this ->sanitarIn ($ this ->IDs );
210214 if ($ sanitarInIDs != "'' " || $ this ->getCFGDef ('ignoreEmpty ' , '0 ' )) {
215+ $ from = $ this ->table . " " . $ this ->_filters ['join ' ];
211216 $ where = $ this ->getCFGDef ('addWhereList ' , '' );
217+
218+ //====== block added by Dreamer to enable filters ======
219+ $ where = ($ where ? $ where . ' AND ' : '' ) . $ this ->_filters ['where ' ];
220+ $ where = sqlHelper::trimLogicalOp ($ where );
221+ //------- end of block -------
222+
223+
212224 if ($ where != '' ) {
213225 $ where = array ($ where );
214226 }
@@ -222,7 +234,8 @@ protected function getDocList()
222234 $ limit = $ this ->LimitSQL ($ this ->getCFGDef ('queryLimit ' , 0 ));
223235 $ fields = $ this ->getCFGDef ('selectFields ' , '* ' );
224236 $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , '' ));
225- $ rs = $ this ->dbQuery ("SELECT {$ fields } FROM {$ this ->table } {$ where } {$ group } {$ this ->SortOrderSQL ($ this ->getPK ())} {$ limit }" );
237+ $ sort = $ this ->SortOrderSQL ($ this ->getPK ());
238+ $ rs = $ this ->dbQuery ("SELECT {$ fields } FROM {$ from } {$ where } {$ group } {$ sort } {$ limit }" );
226239
227240 $ pk = $ this ->getPK (false );
228241 while ($ item = $ this ->modx ->db ->getRow ($ rs )) {
@@ -240,9 +253,16 @@ protected function getChildrenList()
240253 {
241254 $ where = array ();
242255 $ out = array ();
243-
256+ $ from = $ this -> table . " " . $ this -> _filters [ ' join ' ];
244257 $ tmpWhere = $ this ->getCFGDef ('addWhereList ' , '' );
245258 $ tmpWhere = sqlHelper::trimLogicalOp ($ tmpWhere );
259+
260+ //====== block added by Dreamer to enable filters ======
261+ $ tmpWhere = ($ tmpWhere ? $ tmpWhere . ' AND ' : '' ) . $ this ->_filters ['where ' ];
262+ $ tmpWhere = sqlHelper::trimLogicalOp ($ tmpWhere );
263+ //------- end of block -------
264+
265+
246266 if (!empty ($ tmpWhere )) {
247267 $ where [] = $ tmpWhere ;
248268 }
@@ -282,12 +302,10 @@ protected function getChildrenList()
282302 }
283303 $ fields = $ this ->getCFGDef ('selectFields ' , '* ' );
284304 $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , '' ));
305+ $ sort = $ this ->SortOrderSQL ($ this ->getPK ());
306+ $ limit = $ this ->LimitSQL ($ this ->getCFGDef ('queryLimit ' , 0 ));
285307 if ($ sanitarInIDs != "'' " || $ this ->getCFGDef ('ignoreEmpty ' , '0 ' )) {
286- $ rs = $ this ->dbQuery ("SELECT {$ fields } FROM " . $ this ->table . " " . $ where . " " .
287- $ group . " " .
288- $ this ->SortOrderSQL ($ this ->getPK ()) . " " .
289- $ this ->LimitSQL ($ this ->getCFGDef ('queryLimit ' , 0 ))
290- );
308+ $ rs = $ this ->dbQuery ("SELECT {$ fields } FROM {$ from } {$ where } {$ group } {$ sort } {$ limit }" );
291309
292310 $ pk = $ this ->getPK (false );
293311
@@ -308,7 +326,14 @@ public function getChildrenCount()
308326 $ out = 0 ;
309327 $ sanitarInIDs = $ this ->sanitarIn ($ this ->IDs );
310328 if ($ sanitarInIDs != "'' " || $ this ->getCFGDef ('ignoreEmpty ' , '0 ' )) {
329+ $ from = $ this ->table . " " . $ this ->_filters ['join ' ];
311330 $ where = $ this ->getCFGDef ('addWhereList ' , '' );
331+
332+ //====== block added by Dreamer ======
333+ $ where = ($ where ? $ where . ' AND ' : '' ) . $ this ->_filters ['where ' ];
334+ $ where = sqlHelper::trimLogicalOp ($ where );
335+ //------- end of block -------
336+
312337 if ($ where != '' ) {
313338 $ where = array ($ where );
314339 } else {
@@ -352,7 +377,7 @@ public function getChildrenCount()
352377 $ group = $ this ->getGroupSQL ($ this ->getCFGDef ('groupBy ' , $ this ->getPK ()));
353378 $ maxDocs = $ this ->getCFGDef ('maxDocs ' , 0 );
354379 $ limit = $ maxDocs > 0 ? $ this ->LimitSQL ($ this ->getCFGDef ('maxDocs ' , 0 )) : '' ;
355- $ rs = ("SELECT count(*) FROM (SELECT count(*) FROM {$ this -> table } {$ where } {$ group } {$ limit }) as `tmp` " );
380+ $ rs = ("SELECT count(*) FROM (SELECT count(*) FROM {$ from } {$ where } {$ group } {$ limit }) as `tmp` " );
356381 $ out = $ this ->modx ->db ->getValue ($ rs );
357382 }
358383
0 commit comments