Skip to content

Commit c1dc8c6

Browse files
author
Manuel Fischer
committed
Updated the documentation and the release notes for v2.0.0
1 parent 5d610c0 commit c1dc8c6

File tree

3 files changed

+92
-48
lines changed

3 files changed

+92
-48
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ There are [many features which come with NitroNet](https://github.com/namics/Nit
3434
## Future roadmap
3535
[Please look at the milestones regarding the features and time frames of future releases.](https://github.com/namics/NitroNetSitecore/milestones)
3636

37-
**Important features planned for 2018:**
38-
- SC9 compatibility
37+
**Important features planned in the near future:**
38+
- [Possibility to exclude certain Sitecore renderings](https://github.com/namics/NitroNetSitecore/pull/25)
39+
- [Better error message when there are renderings with identical name](https://github.com/namics/NitroNetSitecore/issues/24)
3940
- Youtube tutorial videos
40-
- Demo solution/integration -> [here](https://github.com/hombreDelPez/NitroNet-Demo-Integration-Habitat/tree/feature/nitronet-sitecore-demo) (almost done)
41-
- Extending the documentation
4241

4342
## Contact / Contributing
4443
If you want to submit a bug or request a feature please feel free to open an issue.

docs/releases/2.0.0.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,27 @@
2121

2222
### Update/Installation Instructions
2323

24-
#### Migrate Dynamic Plaeholders
24+
#### Migrate from a Sitecore 8.1 or 8.2 NuGet
25+
26+
1) If you are using a Sitecore 9 NitroNet.Sitecore NuGet then there is nothing to do for you. But if you are currently using a Sitecore 8.1 or 8.2 NitroNet.Sitecore NuGet you first have to become aware of all Visual Studio projects on which the NitroNet.Sitecore NuGet has been installed and write this information down.
27+
28+
- When using Microsoft DI, Unity or CastleWindsor you have to look for the following packages:
29+
- NitroNet.Sitecore.Microsoft.DependencyInjection.Sitecore82
30+
- NitroNet.Sitecore.UnityModules.Sitecore8x
31+
- NitroNet.Sitecore.CastleWindsorModules.Sitecore8x
32+
- When using another IoC framework you have to look for the following package:
33+
- NitroNet.Sitecore.Sitecore8x
34+
35+
2) Uninstall these packages in all Visual Studio projects
36+
37+
3) Install the following new NuGet package in your selected Visual Studio projects:
38+
39+
- When using MS DI:
40+
- `PM >` `Install-Package NitroNet.Sitecore.Microsoft.DependencyInjection.Sitecore90`
41+
- When using another IoC framework:
42+
- `PM >` `Install-Package NitroNet.Sitecore.Sitecore90`
43+
44+
#### Migrate Dynamic Placeholders
2545

2646
Sitecore 9 introduced the dynamic placeholder feature. Please follow the [official documentation](https://doc.sitecore.net/sitecore_experience_platform/developing/developing_with_sitecore/dynamic_placeholders) for more information about when and how to use it. NitroNet for Sitecore uses the new native dynamic placeholders starting with version 2.0. This means if you used NitroNet for Sitecore 1.x in combination with Sitecore 8.x and are upgrading to Sitecore 9 then you need to migrate all existing placeholder keys to the new format.
2747

@@ -34,6 +54,7 @@ This pattern needs to be migrated to the new format: *mykey-{88498EE8-6DAE-470E-
3454
Instructions:
3555

3656
- Add admin page [MigrateDynamicPlaceholders.aspx](https://github.com/namics/NitroNetSitecore/tree/master/docs/releases/utils/MigrateDynamicPlaceholders.aspx) to your solution in folder /sitecore/admin
57+
- Change the setting *Query.MaxItems* to a high value which should be higher than the amount of page items you need to migrate (e.g. 10000)
3758
- Run /sitecore/admin/MigrateDynamicPlaceholders.aspx in your browser. You should first run this script on a single test page and check if the migration works as intended. There are the following GET parameters you can use to migrate the right content.
3859
- database: Sitecore database. Default value: master
3960
- itemId: The dynamic placeholder migration is only processed on this start item. Example: {456B38B8-1C42-48AF-858E-FC58A2FC1491}

docs/releases/utils/MigrateDynamicPlaceholders.aspx

Lines changed: 67 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010
<script language="C#" runat="server">
1111
12-
/// <summary>
13-
/// GET Parameters
14-
///
15-
/// database: The Sitecore database. Example: web
16-
///
17-
/// itemId: The dynamic placeholder migration is only processed on this start item. Example: {456B38B8-1C42-48AF-858E-FC58A2FC1491}
18-
///
19-
/// enableRecursion: This option enables recursion for the start item. Example: true
20-
/// </summary>
12+
/// <summary>
13+
/// This script migrates the "old" dynamic placeholder format to the new format used in Sitecore 9.
14+
///
15+
/// GET Parameters
16+
/// - database: The Sitecore database the script should run on. Example: master
17+
/// - itemId: The dynamic placeholder migration is only processed on this start item. Example: {456B38B8-1C42-48AF-858E-FC58A2FC1491}
18+
/// - enableRecursion: This option enables recursion for the start item. Example: true
19+
/// - allVersions: This option enables the migration of all versions of an item. Example: true
20+
/// </summary>
2121
2222
protected void Page_Load(object sender, EventArgs e)
2323
{
@@ -62,14 +62,16 @@
6262
return;
6363
}
6464
65-
bool isRecursionEnabled;
66-
bool.TryParse(Context.Request.QueryString["enableRecursion"], out isRecursionEnabled);
65+
bool isRecursionEnabled;
66+
bool migrateAllVersions;
67+
bool.TryParse(Context.Request.QueryString["enableRecursion"], out isRecursionEnabled);
68+
bool.TryParse(Context.Request.QueryString["allVersions"], out migrateAllVersions);
6769
6870
var fixRenderings = new UpgradeDynamicPlaceholderHelper(database);
6971
7072
Sitecore.Diagnostics.Log.Info("Dynamic Placeholder Migration: Started", this);
7173
72-
var result = fixRenderings.Iterate(startItem, isRecursionEnabled);
74+
var result = fixRenderings.Iterate(startItem, isRecursionEnabled, migrateAllVersions);
7375
7476
OutputResult(result);
7577
@@ -108,66 +110,88 @@
108110
_database = database;
109111
}
110112
111-
public Dictionary<Item, List<KeyValuePair<string, string>>> Iterate(Item startItem, bool isRecursionEnabled)
113+
public Dictionary<Item, List<KeyValuePair<string, string>>> Iterate(Item startItem, bool isRecursionEnabled, bool migrateAllVersions)
112114
{
113115
var result = new Dictionary<Item, List<KeyValuePair<string, string>>>();
114116
115117
var items = new List<Item>();
116118
117119
if (startItem != null)
118120
{
121+
items.Add(startItem);
122+
119123
if (isRecursionEnabled)
120124
{
121125
items.AddRange(_database.SelectItems(string.Format(ItemsWithPresentationDetailsQuery, startItem.Paths.FullPath)));
122126
}
123-
else
124-
{
125-
items.Add(startItem);
126-
}
127127
}
128128
else
129129
{
130130
items.AddRange(_database.SelectItems(string.Format(ItemsWithPresentationDetailsQuery, "/sitecore/content")));
131131
}
132132
133-
var layoutFieldIds = new[] {FieldIDs.LayoutField, FieldIDs.FinalLayoutField};
134-
135133
foreach (var itemInDefaultLanguage in items)
136134
{
137135
foreach (var itemLanguage in itemInDefaultLanguage.Languages)
138136
{
139137
var item = itemInDefaultLanguage.Database.GetItem(itemInDefaultLanguage.ID, itemLanguage);
140138
if (item.Versions.Count > 0)
141139
{
142-
foreach (var layoutFieldId in layoutFieldIds)
143-
{
144-
var layoutField = item.Fields[layoutFieldId];
140+
ChangeLayout(result, item, FieldIDs.LayoutField, false);
141+
ChangeLayout(result, item, FieldIDs.FinalLayoutField, true);
142+
}
143+
}
144+
}
145145
146-
// Don't convert standard values!
147-
if (layoutField.ContainsStandardValue)
148-
{
149-
continue;
150-
}
146+
return result;
147+
}
151148
152-
var changeResult = ChangeLayoutFieldForItem(item, layoutField);
149+
private void ChangeLayout(Dictionary<Item, List<KeyValuePair<string, string>>> result, Item item, ID layoutFieldId, bool migrateAllVersions)
150+
{
151+
if (migrateAllVersions)
152+
{
153+
var versionCount = item.Versions.GetVersionNumbers().Length;
154+
var versions = item.Versions.GetVersions(false);
153155
154-
if (changeResult.Any())
155-
{
156-
if (!result.ContainsKey(item))
157-
{
158-
result.Add(item, changeResult);
159-
}
160-
else
161-
{
162-
result[item].AddRange(changeResult);
163-
}
164-
}
165-
}
166-
}
156+
if (versions.Length != versionCount)
157+
{
158+
Sitecore.Diagnostics.Log.Warn(string.Format("MigrateDynamicPlaceholders: {0} - Could not load all item versions", item.Name), this);
159+
}
160+
161+
foreach (var itemVersion in versions)
162+
{
163+
ChangeLayoutInternal(result, itemVersion, layoutFieldId);
167164
}
168165
}
166+
else
167+
{
168+
ChangeLayoutInternal(result, item, layoutFieldId);
169+
}
170+
}
169171
170-
return result;
172+
private void ChangeLayoutInternal(Dictionary<Item, List<KeyValuePair<string, string>>> result, Item item, ID layoutFieldId)
173+
{
174+
var layoutField = item.Fields[layoutFieldId];
175+
176+
// Don't convert standard values!
177+
if (layoutField.ContainsStandardValue)
178+
{
179+
return;
180+
}
181+
182+
var changeResult = ChangeLayoutFieldForItem(item, layoutField);
183+
184+
if (changeResult.Any())
185+
{
186+
if (!result.ContainsKey(item))
187+
{
188+
result.Add(item, changeResult);
189+
}
190+
else
191+
{
192+
result[item].AddRange(changeResult);
193+
}
194+
}
171195
}
172196
173197
private List<KeyValuePair<string, string>> ChangeLayoutFieldForItem(Item currentItem, Field field)
@@ -181,7 +205,7 @@
181205
var details = LayoutDefinition.Parse(xml);
182206
183207
var device = details.GetDevice(DefaultDeviceId);
184-
208+
185209
if (device != null && device.Renderings != null)
186210
{
187211
bool requiresUpdate = false;

0 commit comments

Comments
 (0)