Posts

Merging Migraines

Recently, I had to migrate a client's code over to their own repository. At first we were concerned that we would lose our commit history, but I found that git has an easy-to-use solution for this. First, clone the old repository, and check out the branch you want to merge from. Next, clone the new repository, and checkout the branch you want to merge into. You may be surprised to learn that you can add your local clone of the old repository as a remote for your clone of the new repository, using the git add remote <old repository name> <old repository location> command. Follow that with the git remote update command, and now you'll be able to access the old branch using the git merge <old repository name/old branch name> command. Be sure to include the --allow-unrelated-histories flag so it allows your old commits.

Quick Fixes: Rendering Parameters and Standard Values

Although the rendering parameters editor uses a template to define itself, it's important to remember that it does not actually render standard values--even though those values show up when you view the editor. This makes sense; the template is used to control what fields are exposed for editing, rather than to define a data structure for an item, and the editor must rely on the same methods that are used to populate the item editor. There isn't really a good way to get around this, because of the way the information is stored in a parameter string. Sitecore never asks for field values when it calculates the parameter string, only whether or not the key is found in the string. So, in my opinion, the best practice in this situation is to tie these values to the datasource item instead of the rendering parameters, and to avoid setting standard values for rendering parameter templates at all. This way you can take advantage of standard values without confusing your authors.

Quick Fixes: Language Ordering

Say you want to add a language switcher to your site. Simple enough, right? Now say your users want to control the order the languages appear in. Somewhat surprisingly, when you get languages from an item or from the context database, the order they're retrieved in doesn't reflect their order in the content tree. To work around this, you can retrieve the associated items and order them by their sort order using the LanguageManager.GetLanguageItem(language, database) method.

Mega Solutions for Mega Menu Problems

I’ve been working with Sitecore since 2009 when I began my career as a web developer. Here are a few things I’ve learned about navigation along the way. Everybody loves ‘mega’ menus. Every website I’ve ever worked on (bar one) has a mega menu. They’re a quick way to get users around your website to the important bits without lots of scrolling. Here are a few approaches to building them in Sitecore. Use the content tree How: Create a base template all potentially navigable page items will inherit from with a checkbox field indicating whether or not that page is navigable. Then, either create another base template for panels, or integrate it into the navigable item base template and tell users to ignore the extra fields depending on where the page is. Pros No additional items needed. The navigation follows the structure of the tree. If you have simple navigation panels, you can get away with just having one template that covers all the bases. Cons Depending on how flat the site is and ho...