@@ -22,7 +22,7 @@ class ElementChildGridExtension extends DataExtension
2222 * @var array
2323 */
2424 private static $ db = [
25- 'CardColumns ' => 'Varchar(64 ) ' // grid columns at lg breakpoint
25+ 'CardColumns ' => 'Int(4 ) ' // grid columns at lg breakpoint
2626 ];
2727
2828 /**
@@ -75,33 +75,36 @@ public function getColumns() {
7575
7676 /**
7777 * Return the CSS class representing a grid
78- * @param string $lg the number of large columns eg 3. An empty string, the default defers to the selected CardColumns value
78+ * @param int|null $lg the number of large columns eg 3. Default=null meaning defer to the selected CardColumns value
7979 * @param int $max the max grid size. Used to work out the CSS class. $max/$lg = grid 'width'
8080 * @param int $xs number of columns at XS media size, default = 1 col @ 100% width
8181 * @param int $sm number of columns at SM media size, default = 2 cols @ 50% width
8282 * @param int $md number of columns at MD media size, default = 3 cols @ 33.3% width
8383 * @param mixed $xl number of columns at XL media size, if supported, default = none
8484 */
85- public function ColumnClass ($ lg = '' , $ max = 12 , $ xs = 1 , $ sm = 2 , $ md = 3 , $ xl = '' ) : string
85+ public function ColumnClass ($ lg = null , $ max = 12 , $ xs = 1 , $ sm = 2 , $ md = 3 , $ xl = null ) : string
8686 {
87- // If there are no override columns from code, use the saved field value
88- $ lg = trim ($ lg );
89- if ($ lg ) {
90- $ columns = $ lg ;
87+
88+ if (is_int ($ lg )) {
89+ $ desktopColumns = $ lg ;
9190 } else {
92- $ columns = $ this ->owner ->CardColumns ;
91+ $ desktopColumns = $ this ->owner ->CardColumns ;
9392 }
9493
9594 $ max = trim ($ max );
9695 if (!$ max ) {
9796 $ max = $ this ->getConfigurator ()->config ()->get ('max_columns ' );
9897 }
9998
100- if (!$ columns ) {
99+ if (!$ desktopColumns ) {
101100 return '' ;
102101 } else {
103102
104- $ gridLg = ceil ($ max / $ columns );
103+ $ xs = $ this ->getConfigurator ()->getGridValue ($ xs , $ desktopColumns );
104+ $ sm = $ this ->getConfigurator ()->getGridValue ($ sm , $ desktopColumns );
105+ $ md = $ this ->getConfigurator ()->getGridValue ($ md , $ desktopColumns );
106+
107+ $ gridLg = ceil ($ max / $ desktopColumns );
105108 $ gridXs = ceil ($ max / $ xs );
106109 $ gridSm = ceil ($ max / $ sm );
107110 $ gridMd = ceil ($ max / $ md );
@@ -115,6 +118,7 @@ public function ColumnClass($lg = '', $max = 12, $xs = 1, $sm = 2, $md = 3, $xl
115118
116119 $ gridXl = null ;
117120 if ($ xl > 0 ) {
121+ $ xl = $ this ->getConfigurator ()->getGridValue ($ xl , $ desktopColumns );
118122 $ gridXl = ceil ($ max / $ xl );
119123 }
120124 if ($ gridXl ) {
0 commit comments