Skip to content

Commit

Permalink
Added code for using dynamic placeholders with Sitecore MVC
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbert committed Jan 9, 2015
1 parent 9d27754 commit cb02f68
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
*.cs diff=csharp
88 changes: 88 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Custom
_Libraries/

# MAC OS
.DS_Store

# Windows OS
Thumbs.db

# Visual Studio
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.o
*.lo
*.la
*.al
.libs
*.so
*.so.[0-9]*
*.a
*.pyc
*.pyo
*.rej
*.Publish.xml
*~
.*.swp
*.lib
*.sbr
*.sln.ide
[Bb]in
[Dd]ebug/
[Rr]elease*/
obj/
_ReSharper*/
[Tt]est[Rr]esult*
BuiltFiles_*
Code/packages/
Source/packages/
FakesAssemblies/

# Dreamweaver
_notes/

# Sitecore
TDS_Build/
IconCache/
_Deploy/
T4RenderCache/
*.csproj.sitecore

# PHP/Web Storm
.idea/

# SASS
.sass-cache/

# Node Modules
node_modules/
node_modules/*

# Compiled CSS
_compiled-css/

# Comiled JS
_compiled-js/

# Xcode
build/*
*.xcuserdatad

# Eclipse

# Flash Builder
22 changes: 22 additions & 0 deletions Source/DynamicPlaceholders.Mvc.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamicPlaceholders.Mvc", "DynamicPlaceholders.Mvc\DynamicPlaceholders.Mvc.csproj", "{44B2E88A-FDFB-4671-BA1A-08BF35CAC6D0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{44B2E88A-FDFB-4671-BA1A-08BF35CAC6D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44B2E88A-FDFB-4671-BA1A-08BF35CAC6D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44B2E88A-FDFB-4671-BA1A-08BF35CAC6D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44B2E88A-FDFB-4671-BA1A-08BF35CAC6D0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
60 changes: 60 additions & 0 deletions Source/DynamicPlaceholders.Mvc/DynamicPlaceholders.Mvc.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{44B2E88A-FDFB-4671-BA1A-08BF35CAC6D0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DynamicPlaceholders.Mvc</RootNamespace>
<AssemblyName>DynamicPlaceholders.Mvc</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Sitecore.Mvc">
<HintPath>..\..\_Libraries\Sitecore.Mvc.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Extensions\SitecoreHelperExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Sitecore.Mvc.Helpers;
using Sitecore.Mvc.Presentation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace DynamicPlaceholders.Mvc.Extensions
{
public static class SitecoreHelperExtensions
{
public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string placeholderName)
{
var currentRenderingId = RenderingContext.Current.Rendering.UniqueId;

return helper.Placeholder(string.Format("{0}_{1}", placeholderName, currentRenderingId));
}
}
}
36 changes: 36 additions & 0 deletions Source/DynamicPlaceholders.Mvc/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DynamicPlaceholders.Mvc")]
[assembly: AssemblyDescription("Allows for the creation of dynamic placeholders in Sitecore MVC")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Fortis Collections")]
[assembly: AssemblyProduct("DynamicPlaceholders")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5dcf1c1e-3606-4994-ab15-ff1159c41b71")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
11 changes: 11 additions & 0 deletions Source/DynamicPlaceholders.Mvc/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

0 comments on commit cb02f68

Please sign in to comment.