-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from thewebmen/feature/single-article-grid-blo…
…ck-and-translations Single article grid element and updated translations
- Loading branch information
Showing
10 changed files
with
200 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
|
||
namespace TheWebmen\Articles\ElementalGrid; | ||
|
||
use DNADesign\Elemental\Models\BaseElement; | ||
use SilverStripe\CMS\Model\SiteTree; | ||
use SilverStripe\Forms\CheckboxField; | ||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\Forms\TextField; | ||
use SilverStripe\Forms\TreeDropdownField; | ||
use TheWebmen\Articles\Pages\ArticlePage; | ||
|
||
/** | ||
* Class ElementArticle | ||
* @package TheWebmen\Articles\ElementalGrid | ||
* | ||
* @method ArticlePage ArticlePage() | ||
*/ | ||
class ElementArticle extends BaseElement | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private static $table_name = 'Element_Article'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $singular_name = 'Article'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $plural_name = 'Articles'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $description = 'Show an article in a grid element'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $icon = 'font-icon-p-list'; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $has_one = [ | ||
'ArticlePage' => ArticlePage::class, | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $db = [ | ||
'ShowMoreArticlesButton' => 'Boolean', | ||
'ShowMoreArticlesButtonText' => 'Varchar(255)', | ||
]; | ||
|
||
public function getCMSFields(): FieldList | ||
{ | ||
$fields = parent::getCMSFields(); | ||
|
||
$fields->addFieldsToTab( | ||
'Root.Main', | ||
[ | ||
TreeDropdownField::create('ArticlePageID', _t(__CLASS__ . '.ARTICLETOSHOW'), ArticlePage::class), | ||
] | ||
); | ||
|
||
$fields->removeByName( | ||
[ | ||
'ShowMoreArticlesButton', | ||
'ShowMoreArticlesButtonText', | ||
] | ||
); | ||
|
||
$fields->addFieldsToTab( | ||
'Root.Main', | ||
[ | ||
CheckboxField::create( | ||
'ShowMoreArticlesButton', | ||
_t('TheWebmen\Articles\ElementalGrid.SHOWMOREBUTTON', "Show 'more articles' button") | ||
), | ||
TextField::create( | ||
'ShowMoreArticlesButtonText', | ||
_t('TheWebmen\Articles\ElementalGrid.SHOWMOREBUTTONTEXT', "Show 'more articles' button") | ||
) | ||
->displayIf('ShowMoreArticlesButton') | ||
->isChecked() | ||
->end(), | ||
] | ||
); | ||
|
||
$this->extend('onAfterUpdateCMSFields', $fields); | ||
|
||
return $fields; | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return 'Article'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.