From 6695fc1aef8838c4c09e3729cd4c9ebad221bf0c Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Sun, 1 Dec 2024 20:01:33 -0600 Subject: [PATCH] FEATURE Initial templates --- src/Page/RecipePage.php | 51 ++++++++--- .../Page/Layout/RecipeCategoryPage.ss | 83 ++++++++++++++++++ .../RecipeBook/Page/Layout/RecipeLanding.ss | 50 +++++++++++ .../RecipeBook/Page/Layout/RecipePage.ss | 87 +++++++++++++++++++ 4 files changed, 259 insertions(+), 12 deletions(-) create mode 100644 templates/Dynamic/RecipeBook/Page/Layout/RecipeCategoryPage.ss create mode 100644 templates/Dynamic/RecipeBook/Page/Layout/RecipeLanding.ss create mode 100644 templates/Dynamic/RecipeBook/Page/Layout/RecipePage.ss diff --git a/src/Page/RecipePage.php b/src/Page/RecipePage.php index d727316..703ec81 100644 --- a/src/Page/RecipePage.php +++ b/src/Page/RecipePage.php @@ -2,24 +2,26 @@ namespace Dynamic\RecipeBook\Page; -use Dynamic\RecipeBook\Model\RecipeDirection; -use Dynamic\RecipeBook\Model\RecipeIngredient; -use SilverStripe\Forms\FieldGroup; -use SilverStripe\Forms\FieldList; -use SilverStripe\Forms\GridField\GridField; -use SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter; -use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; -use SilverStripe\Forms\GridField\GridFieldEditButton; -use SilverStripe\Forms\ReadonlyField; -use SilverStripe\Forms\TextField; +use SilverStripe\ORM\DB; +use SilverStripe\Assets\Image; use SilverStripe\ORM\DataList; use SilverStripe\ORM\DataObject; -use SilverStripe\ORM\DB; +use SilverStripe\Forms\FieldList; +use SilverStripe\Forms\TextField; use SilverStripe\ORM\HasManyList; +use SilverStripe\Forms\FieldGroup; use SilverStripe\ORM\ManyManyList; +use SilverStripe\Forms\ReadonlyField; +use SilverStripe\Forms\GridField\GridField; +use Dynamic\RecipeBook\Model\RecipeDirection; +use Dynamic\RecipeBook\Model\RecipeIngredient; +use SilverStripe\AssetAdmin\Forms\UploadField; use SilverStripe\Versioned\GridFieldArchiveAction; -use Symbiote\GridFieldExtensions\GridFieldAddExistingSearchButton; +use SilverStripe\Forms\GridField\GridFieldEditButton; use Symbiote\GridFieldExtensions\GridFieldOrderableRows; +use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; +use Symbiote\GridFieldExtensions\GridFieldAddExistingSearchButton; +use SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter; /** * Class RecipePage @@ -60,6 +62,13 @@ class RecipePage extends \Page 'Difficulty' => 'Varchar(255)', ]; + /** + * @var array + */ + private static $has_one = [ + 'Image' => Image::class, + ]; + /** * @var array */ @@ -84,6 +93,13 @@ class RecipePage extends \Page ], ]; + /** + * @var string[] + */ + private static $owns = [ + 'Image', + ]; + /** * @var array */ @@ -113,6 +129,13 @@ class RecipePage extends \Page public function getCMSFields(): FieldList { $this->beforeUpdateCMSFields(function (FieldList $fields) { + $fields->insertAfter( + 'Title', + UploadField::create('Image') + ->setAllowedMaxFileNumber(1) + ->setAllowedFileCategories('image') + ->setFolderName('Uploads/Recipe/Image') + ); $fields->addFieldsToTab( 'Root.Main', @@ -134,6 +157,10 @@ public function getCMSFields(): FieldList 'Content' ); + $fields->dataFieldByName('Content') + ->setTitle('Summary') + ->setRows(5); + if ($this->exists()) { $fields->addFieldToTab( 'Root.Ingredients', diff --git a/templates/Dynamic/RecipeBook/Page/Layout/RecipeCategoryPage.ss b/templates/Dynamic/RecipeBook/Page/Layout/RecipeCategoryPage.ss new file mode 100644 index 0000000..1c38a3a --- /dev/null +++ b/templates/Dynamic/RecipeBook/Page/Layout/RecipeCategoryPage.ss @@ -0,0 +1,83 @@ +
+ +
+ +<% if $paginatedList.MoreThanOnePage %> + +<% end_if %> \ No newline at end of file diff --git a/templates/Dynamic/RecipeBook/Page/Layout/RecipeLanding.ss b/templates/Dynamic/RecipeBook/Page/Layout/RecipeLanding.ss new file mode 100644 index 0000000..15b67a7 --- /dev/null +++ b/templates/Dynamic/RecipeBook/Page/Layout/RecipeLanding.ss @@ -0,0 +1,50 @@ +
+
+ <% loop $paginatedList %> +
+ <% if $CategoryImage %> + + <% else %> + + <% end_if %> +
+

$Title

+ <% if $Content %>

$Content

<% end_if %> +
+
+ View All +
+
+ <% end_loop %> +
+
+ +<% if $paginatedList.MoreThanOnePage %> + +<% end_if %> \ No newline at end of file diff --git a/templates/Dynamic/RecipeBook/Page/Layout/RecipePage.ss b/templates/Dynamic/RecipeBook/Page/Layout/RecipePage.ss new file mode 100644 index 0000000..491a3f1 --- /dev/null +++ b/templates/Dynamic/RecipeBook/Page/Layout/RecipePage.ss @@ -0,0 +1,87 @@ +
+ +
+
+ $Image.Title +
+
+ + +
+
+

$Title

+
+
+ Prep: $PreparationTime minutes +
+
+ Cook: $CookTime minutes +
+
+ Servings: $Servings +
+
+
+
+ + +
+
+
+

Share This Recipe:

+ + + + + + + + + + + + + + + +
+
+
+ + +
+
+

About this Recipe

+

$Content

+
+
+ + +
+
+

Ingredients

+
    + <% loop $Ingredients.Sort('Sort') %> +
  • + + +
  • + <% end_loop %> +
+
+
+

Instructions

+ <% loop $Directions.Sort('Sort') %> +
+ $Pos. + $Title +
+ <% end_loop %> +
+
+
+ + +
+ $ElementalArea +
\ No newline at end of file