-
-
Save hailwood/3fde24f4c6e83a06b487 to your computer and use it in GitHub Desktop.
Put the .xml files in your {ide-settings-dir}/config/templates - put the .php files in {ide-settings-dir}/fileTemplates
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
<?php | |
/** | |
* Class CustomSiteConfig | |
* | |
* @property SiteConfig \$owner | |
*/ | |
class CustomSiteConfig extends DataExtension { | |
static \$db = [ | |
'AddressLineOne' => 'Varchar(255)', | |
'AddressLineTwo' => 'Varchar(255)', | |
'AddressLineThree' => 'Varchar(255)', | |
'AddressLineFour' => 'Varchar(255)', | |
'Phone' => 'Varchar(255)', | |
'Fax' => 'Varchar(255)', | |
'Email' => 'Varchar(255)', | |
'CustomHeaderOutput' => 'Text', | |
'CustomFooterOutput' => 'Text' | |
]; | |
static \$has_one = array( | |
'PrivacyPolicyPage' => 'SiteTree', | |
'TermsAndConditionsPage' => 'SiteTree' | |
); | |
public function updateCMSFields(FieldList \$fields) { | |
/** | |
* Linked Pages | |
*/ | |
\$fields->addFieldsToTab('Root.Main', [ | |
TextField::create('AddressLineOne'), | |
TextField::create('AddressLineTwo'), | |
TextField::create('AddressLineThree'), | |
TextField::create('AddressLineFour'), | |
TextField::create('Phone'), | |
TextField::create('Fax'), | |
EmailField::create('Email'), | |
]); | |
/** | |
* Advanced Options | |
*/ | |
\$fields->addFieldsToTab('Root.Advanced', [ | |
TextareaField::create('CustomHeaderOutput', 'Custom Header Tags'), | |
TextareaField::create('CustomFooterOutput', 'Custom Footer Tags') | |
]); | |
} | |
} |
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
<?php | |
class ${NAME} extends ${Extends} { | |
} | |
class ${NAME}_Controller extends ${Extends}_Controller { | |
} |
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
<?php | |
class ${NAME} extends DataObject { | |
protected static \$db = [ | |
'Title' => 'Varchar(255)', | |
'SortOrder' => 'Int' | |
]; | |
protected static \$default_sort = 'SortOrder'; | |
public function getCMSFields(){ | |
\$fields = new FieldList([ | |
TextField::create('Title') | |
]); | |
return \$fields; | |
} | |
public function canView(\$member = null) { | |
return Permission::check('CMS_ACCESS_CMSMain', 'any', \$member); | |
} | |
public function canEdit(\$member = null) { | |
return Permission::check('CMS_ACCESS_CMSMain', 'any', \$member); | |
} | |
public function canDelete(\$member = null) { | |
return Permission::check('CMS_ACCESS_CMSMain', 'any', \$member); | |
} | |
public function canCreate(\$member = null) { | |
return Permission::check('CMS_ACCESS_CMSMain', 'any', \$member); | |
} | |
} |
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
<?php | |
class ${NAME} extends ModelAdmin { | |
private static \$managed_models = array( | |
'${Model_Class}' => ['title' => '${Model_Title}'] | |
); | |
private static \$url_segment = '${URL_Segment}'; | |
private static \$menu_title = '${Menu_Title}'; | |
public function getEditForm(\$id = null, \$fields = null) { | |
\$form = parent::getEditForm(\$id, \$fields); | |
\$gridFieldName = \$this->sanitiseClassName(\$this->modelClass); | |
/** @var GridField \$gridField */ | |
\$gridField = \$form->Fields()->fieldByName(\$gridFieldName); | |
if (\$this->modelClass === '${Model_Class}') { | |
// modify the list view. | |
\$gridField->getConfig() | |
->addComponent(new GridFieldFilterHeader()); | |
} | |
return \$form; | |
} | |
} |
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
<?php | |
#set( $Extends = 'Page' ) | |
class ${NAME} extends ${Extends} { | |
} | |
class ${NAME}_Controller extends ${Extends}_Controller { | |
} |
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
<templateSet group="SilverStripe PHP"> | |
<template name="has_many" value="private static $has_many = [ $END$ ];" description="Has many" toReformat="true" toShortenFQNames="true"> | |
<context /> | |
</template> | |
<template name="cmsFields" value="public function getCMSFields(){ $this->beforeUpdateCMSFields(function(FieldList $fields) { 		$END$ 	}); 	$fields = parent::getCMSFields(); 	return $fields; }" description="GetCMSFields() function" toReformat="false" toShortenFQNames="true"> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="has_one" value="private static $has_one = [ $END$ ];" description="Has one" toReformat="true" toShortenFQNames="true"> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="db_fields" value="private static $db = [ $END$ ];" description="DB Fields" toReformat="true" toShortenFQNames="true"> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="field" value="$fields->addFieldToTab('$TAB$', $FIELDTYPE$::create('$FIELDTITLE$', '$FIELDTITLE$'), '$BEFORE$');" description="Add Field" toReformat="true" toShortenFQNames="true"> | |
<variable name="TAB" expression="" defaultValue=""Root.Main"" alwaysStopAt="true" /> | |
<variable name="FIELDTYPE" expression="" defaultValue=""TextField"" alwaysStopAt="true" /> | |
<variable name="FIELDTITLE" expression="underscoresToSpaces(String)" defaultValue="" alwaysStopAt="true" /> | |
<variable name="BEFORE" expression="" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="create:UF" value="UploadField::create('$NAME$', '$END$')" description="SS Upload Field" toReformat="false" toShortenFQNames="true"> | |
<variable name="NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<context /> | |
</template> | |
<template name="many_many" value="private static $many_many = [ $END$ ];" description="Many many" toReformat="true" toShortenFQNames="true"> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="field_labels" value="private static $field_labels = [ $END$ ];" description="Silverstripe Field Labels" toReformat="true" toShortenFQNames="true"> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="can" value="public function canView($member = null) { 		return $CAN$; 	} 	public function canEdit($member = null) { 		return $CAN$; 	} 	public function canDelete($member = null) { 		return $CAN$; 	} 	public function canCreate($member = null) { 		return $CAN$; 	}" description="All canXXX Actions" toReformat="true" toShortenFQNames="true"> | |
<variable name="CAN" expression="" defaultValue="true" alwaysStopAt="true" /> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="canDefault" value="public function canView($member = null) { return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); } public function canEdit($member = null) { return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); } public function canDelete($member = null) { return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); } public function canCreate($member = null) { return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); }" description="All default canXXX Actions" toReformat="true" toShortenFQNames="true"> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="gridfield_gallery" value="$$$NAME$Config = new GridFieldConfig_RecordEditor(); $$$NAME$Config->removeComponentsByType('GridFieldAddNewButton'); $$$NAME$Config->addComponent($bulkUploadConfig = new GridFieldBulkUpload()); $$$NAME$Config->addComponent(new GridFieldSortableRows('SortOrder')); $$$NAME$Config->addComponent(new GridFieldGalleryTheme('Image')); $bulkUploadConfig->setUfSetup('setFolderName', 'Images/$LOCATION$'); $$$NAME$ = new GridField("$NAME$GridField", "$TITLE$", $this->$RELATION$(), $$$NAME$Config); $fields->addFieldToTab('Root.$TAB$', $$$NAME$);" description="Gallery Theme Gridfield" toReformat="true" toShortenFQNames="true"> | |
<variable name="NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="LOCATION" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="TITLE" expression="" defaultValue="NAME" alwaysStopAt="true" /> | |
<variable name="RELATION" expression="" defaultValue="NAME" alwaysStopAt="true" /> | |
<variable name="TAB" expression="" defaultValue="NAME" alwaysStopAt="true" /> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="gridfield_relation_editor" value="$$$NAME$Config = new GridFieldConfig_RelationEditor(); $$$NAME$Config->addComponent(new GridFieldSortableRows('SortOrder')); $$$NAME$ = new GridField("$NAME$GridField", "$TITLE$", $this->$RELATION$(), $$$NAME$Config); $fields->addFieldToTab('Root.$TAB$', $$$NAME$);" description="Relation Editor Gridfield" toReformat="true" toShortenFQNames="true"> | |
<variable name="NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="TITLE" expression="" defaultValue="NAME" alwaysStopAt="true" /> | |
<variable name="RELATION" expression="" defaultValue="NAME" alwaysStopAt="true" /> | |
<variable name="TAB" expression="" defaultValue="NAME" alwaysStopAt="true" /> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="gridfield_record_editor" value="$$$NAME$Config = new GridFieldConfig_RecordEditor(); $$$NAME$Config->addComponent(new GridFieldSortableRows('SortOrder')); $$$NAME$ = new GridField("$NAME$GridField", "$TITLE$", $this->$RELATION$(), $$$NAME$Config); $fields->addFieldToTab('Root.$TAB$', $$$NAME$);" description="Record Editor Gridfield" toReformat="true" toShortenFQNames="true"> | |
<variable name="NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="TITLE" expression="" defaultValue="NAME" alwaysStopAt="true" /> | |
<variable name="RELATION" expression="" defaultValue="NAME" alwaysStopAt="true" /> | |
<variable name="TAB" expression="" defaultValue="NAME" alwaysStopAt="true" /> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="DisplayedDropdownField" value="DropdownField::create('Displayed', 'Displayed', [1 => 'Displayed', 0 => 'Hidden']),$END$" description="Silverstripe Displayed Dropdown Field" toReformat="false" toShortenFQNames="true"> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="defaults" value="private static $defaults = [ 	'$LABEL$' => $VALUE$$END$ ];" description="Default Values" toReformat="true" toShortenFQNames="true"> | |
<variable name="LABEL" expression="" defaultValue=""Displayed"" alwaysStopAt="true" /> | |
<variable name="VALUE" expression="" defaultValue=""true"" alwaysStopAt="true" /> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="default_sort" value="private static $default_sort = '$SORT$';$END$" description="Default Sort Order" toReformat="true" toShortenFQNames="true"> | |
<variable name="SORT" expression="" defaultValue=""SortOrder"" alwaysStopAt="true" /> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
</templateSet> |
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
<templateSet group="SilverStripe Template"> | |
<template name="iif" value="<% if $$$ifVar$ %>$ACTION$$END$<% end_if %>" description="An inline if block" toReformat="true" toShortenFQNames="true"> | |
<variable name="ifVar" expression="" defaultValue=""First"" alwaysStopAt="true" /> | |
<variable name="ACTION" expression="" defaultValue=""active"" alwaysStopAt="true" /> | |
<context /> | |
</template> | |
<template name="iife" value="<% if $$$ifVar$ %>$ACTION$<% else %>$ACTION2$$END$<% end_if %>" description="An inline if-else block" toReformat="true" toShortenFQNames="true"> | |
<variable name="ifVar" expression="" defaultValue=""First"" alwaysStopAt="true" /> | |
<variable name="ACTION" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="ACTION2" expression="" defaultValue="" alwaysStopAt="true" /> | |
<context /> | |
</template> | |
</templateSet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment