Skip to content

Instantly share code, notes, and snippets.

@komainu85
komainu85 / PageCode.ts
Last active August 29, 2015 14:16
Sitecore SPEAK PageCode TypeScript
import Speak = require("sitecore/shell/client/Speak/Assets/lib/core/1.2/SitecoreSpeak");
class PageCode extends Speak.PageCode {
initialize() {
}
}
Sitecore.Speak.pageCode(["bootstrap", "scPipeline"], new PageCode());
@komainu85
komainu85 / Bind Sitecore components to DataSource
Last active August 29, 2015 14:16
Auto bind Sitecore components to DataSource (Forked from Jamie Little)
public void BindDatasourceToSitecoreControls()
{
BindDatasourceToSitecoreControls(DataSourceItem);
}
public void BindDatasourceToSitecoreControls(Item dataSource)
{
if (Controls.Count > 0)
{
BindControls(this.Controls, dataSource);
@komainu85
komainu85 / Is Content Item
Last active August 29, 2015 14:17
Sitecore Is Content / Media Item
Sitecore.Context.Item.Paths.IsContentItem
@komainu85
komainu85 / Add Item from template
Created March 13, 2015 15:45
Sitecore Add Item from Template
Sitecore.Data.Items.ItemUtil.AddFromTemplate(string itemName, string templatePath, Item parent);
@komainu85
komainu85 / Edit Item
Created March 13, 2015 15:47
Edit Sitecore Item
using (new EditContext(scItem))
{
redirectItem.Fields["fieldName"].Value = "";
}
@komainu85
komainu85 / Get Item from Event
Created March 13, 2015 15:48
Sitecore get item from event
var item = Sitecore.Events.Event.ExtractParameter<Item>(args, 0);
@komainu85
komainu85 / ICustomRepositoryActions
Created March 20, 2015 13:19
ICustomRepositoryActions
public interface ICustomRepositoryActions<T> : Sitecore.Services.Core.IRepository<T> where T : IEntityIdentity
{
string DoSometingCustom();
}
@komainu85
komainu85 / ICustomRepositoryActions
Created March 20, 2015 13:19
ICustomRepositoryActions
public class EntityRespository :ICustomRepositoryActions<Entity>
{
public IQueryable<Entity> GetAll()
{
throw new NotImplementedException();
}
public Entity FindById(string id)
{
throw new NotImplementedException();
@komainu85
komainu85 / EntityController
Created March 20, 2015 13:20
EntityController
[ServicesController]
public class EntityController : EntityService<Entity>
{
private ICustomRepositoryActions<Entity> _customRepositoryActions;
public EntityController(ICustomRepositoryActions<Entity> repository)
: base(repository)
{
_customRepositoryActions = repository;
}
@komainu85
komainu85 / Web API Controller Action
Created March 20, 2015 13:37
Web API Controller Action
[HttpGet]
[ActionName("DoSomethingCustom")]
public string Get()
{
return "Hello World";
}