diff --git a/code/dataobjects/Block.php b/code/dataobjects/Block.php index 9c5560e..5e7b7f5 100644 --- a/code/dataobjects/Block.php +++ b/code/dataobjects/Block.php @@ -10,14 +10,16 @@ class Block extends DataObject //public static $default_sort = 'SortOrder'; private static $db = array( - 'Name' => 'Varchar', + 'Name' => 'Varchar(255)', 'Header' => "Enum('None, h1, h2, h3, h4, h5, h6')", 'Content' => 'HTMLText', 'Link' => 'Varchar', 'VideoURL' => 'Varchar', 'Template' => 'Varchar', 'Active' => 'Boolean(1)', - 'ImageCropMethod' => 'Enum("CroppedFocusedImage, SetRatioSize, CroppedImage, Fit, Fill", "CroppedFocusedImage")' + 'ImageCropMethod' => 'Enum("CroppedFocusedImage, SetRatioSize, CroppedImage, Fit, Fill", "CroppedFocusedImage")', + 'ContentAsColumns' => 'Boolean(0)', + 'ExtraCssClasses' => 'Varchar' ); private static $many_many = array( @@ -124,9 +126,10 @@ public function getCMSFields() $fields->addFieldToTab("Root.Settings", $globalwarningfield); } - $fields->addFieldsToTab("Root.Main", new TextField('Name', 'Name')); - $fields->addFieldsToTab("Root.Main", new DropdownField('Header', 'Use name as header', $this->dbObject('Header')->enumValues()), 'Content'); - $fields->addFieldsToTab("Root.Main", new HTMLEditorField('Content', 'Content')); + $fields->addFieldToTab("Root.Main", new TextField('Name', 'Name')); + $fields->addFieldToTab("Root.Main", new DropdownField('Header', 'Use name as header', $this->dbObject('Header')->enumValues()), 'Content'); + $fields->addFieldToTab("Root.Main", new HTMLEditorField('Content', 'Content')); + $fields->addFieldToTab('Root.Main', CheckboxField::create('ContentAsColumns')); $imgField = new SortableUploadField('Images', 'Images'); $imgField->allowedExtensions = array('jpg', 'gif', 'png'); @@ -173,8 +176,9 @@ public function getCMSFields() } // Settings tab - $fields->addFieldsToTab("Root.Settings", new CheckboxField('Active', 'Active')); - $fields->addFieldsToTab("Root.Settings", new TextField('Link', 'Link')); + $fields->addFieldToTab("Root.Settings", new CheckboxField('Active', 'Active')); + $fields->addFieldToTab("Root.Settings", new TextField('Link', 'Link')); + $fields->addFieldToTab("Root.Settings", TextField::create('ExtraCssClasses')); $PagesConfig = GridFieldConfig_RelationEditor::create(10); $PagesConfig->removeComponentsByType('GridFieldAddNewButton'); @@ -314,6 +318,17 @@ function file_ext_strip($filename) return preg_replace('/\.[^.]*$/', '', $filename); } + /** + * @return string + */ + public function getExtraClasses(){ + $classes = $this->ExtraCssClasses; + if($this->ContentAsColumns){ + $classes .= ' css-columns'; + } + return $classes; + } + /** * @param int $img_id * @param $width diff --git a/templates/BlockTemplates/Block.ss b/templates/BlockTemplates/Block.ss index da9274d..454fb4d 100644 --- a/templates/BlockTemplates/Block.ss +++ b/templates/BlockTemplates/Block.ss @@ -1,9 +1,11 @@ -
+
- <% if $Header != "None" %><{$Header}>$Name<% end_if %> - - $Content - +
+ <% if $Header != "None" %><{$Header}>$Name<% end_if %> +
+ $Content +
+
<% if Images %> <% loop Images.Sort('SortOrder') %> diff --git a/templates/BlockTemplates/Full width image.ss b/templates/BlockTemplates/Full width image.ss index 49df6d6..6c277fd 100644 --- a/templates/BlockTemplates/Full width image.ss +++ b/templates/BlockTemplates/Full width image.ss @@ -1,4 +1,4 @@ -
+
<% if $Header != "None" %><{$Header}>$Name<% end_if %> @@ -9,6 +9,10 @@ <% end_loop %> <% end_if %> - $Content +
+
+ $Content +
+
\ No newline at end of file diff --git a/templates/BlockTemplates/MultiColumn.ss b/templates/BlockTemplates/MultiColumn.ss index 5987d75..138eb72 100644 --- a/templates/BlockTemplates/MultiColumn.ss +++ b/templates/BlockTemplates/MultiColumn.ss @@ -1,18 +1,17 @@ -
-
- <% if $Header != "None" %> -
- <{$Header}>$Name -
- <% end_if %> - <% loop $Blocks.Sort('SortOrder') %> +
+ <% if $Header != "None" %> +
+ <{$Header}>$Name +
+ <% end_if %> -
- $Me -
+ <% loop $Blocks.Sort('SortOrder') %> - <% end_loop %> +
+ $Me +
-
-
\ No newline at end of file + <% end_loop %> + +
diff --git a/templates/BlockTemplates/Pic-Text-Wrap.ss b/templates/BlockTemplates/Pic-Text-Wrap.ss index e3ee695..99522b8 100644 --- a/templates/BlockTemplates/Pic-Text-Wrap.ss +++ b/templates/BlockTemplates/Pic-Text-Wrap.ss @@ -1,7 +1,4 @@ -
-
- <% if $Header != "None" %><{$Header}>$Name<% end_if %> -
+
<% if Images %> @@ -11,7 +8,12 @@ <% end_loop %> <% end_if %> +
+ <% if $Header != "None" %><{$Header}>$Name<% end_if %> +
+ $Content +
+
- $Content
\ No newline at end of file diff --git a/templates/BlockTemplates/Pic2-Text2-Wrap.ss b/templates/BlockTemplates/Pic2-Text2-Wrap.ss index b946595..293aa6a 100644 --- a/templates/BlockTemplates/Pic2-Text2-Wrap.ss +++ b/templates/BlockTemplates/Pic2-Text2-Wrap.ss @@ -1,8 +1,4 @@ -
-
- <% if $Header != "None" %><{$Header}>$Name<% end_if %> -
- +
<% if Images %> <% loop Images.Sort('SortOrder') %> @@ -11,7 +7,11 @@ <% end_loop %> <% end_if %> - - $Content +
+ <% if $Header != "None" %><{$Header}>$Name<% end_if %> +
+ $Content +
+
\ No newline at end of file diff --git a/templates/BlockTemplates/PictureList.ss b/templates/BlockTemplates/PictureList.ss index 3296e51..7ac0cf6 100644 --- a/templates/BlockTemplates/PictureList.ss +++ b/templates/BlockTemplates/PictureList.ss @@ -1,19 +1,23 @@ -
+
- <% if $Header != "None" %><{$Header}>$Name<% end_if %> - $Content +
+ <% if $Header != "None" %><{$Header}>$Name<% end_if %> +
+ $Content +
+
+
- - + diff --git a/templates/BlockTemplates/Text-Pic-Wrap.ss b/templates/BlockTemplates/Text-Pic-Wrap.ss index 2fd6027..379eb35 100644 --- a/templates/BlockTemplates/Text-Pic-Wrap.ss +++ b/templates/BlockTemplates/Text-Pic-Wrap.ss @@ -1,7 +1,4 @@ -
-
- <% if $Header != "None" %><{$Header}>$Name<% end_if %> -
+
<% if Images %> @@ -11,7 +8,11 @@ <% end_loop %> <% end_if %> - - $Content +
+ <% if $Header != "None" %><{$Header}>$Name<% end_if %> +
+ $Content +
+
\ No newline at end of file diff --git a/templates/BlockTemplates/Text2-Pic2-Wrap.ss b/templates/BlockTemplates/Text2-Pic2-Wrap.ss index d0c6252..88f3fa8 100644 --- a/templates/BlockTemplates/Text2-Pic2-Wrap.ss +++ b/templates/BlockTemplates/Text2-Pic2-Wrap.ss @@ -1,9 +1,4 @@ -
- <% if $Header != "None" %> -
- <% if $Header != "None" %><{$Header}>$Name<% end_if %> -
- <% end_if %> +
<% if $Images %> @@ -13,7 +8,11 @@ <% end_loop %> <% end_if %> - - $Content +
+ <% if $Header != "None" %><{$Header}>$Name<% end_if %> +
+ $Content +
+
\ No newline at end of file