Sitecore 8: O atribute Hostname retorna vazio mesmo contendo um valor na configuração do site. O que pode ser?

Recentemente eu trabalhei em um projeto de Sitecore onde eu estava criando uma lista de sites dinamicamente assim:

sites = SiteManager.GetSites().Select(s => new SiteInfo(s.Properties)).ToList();

em mode de debug eu conseguia ver os valores do atributo hostname definidos corretamente para a configuração do site em questão. Mas ao construir o objeto ele não carregava o valor do hostname.

Eu verifiquei a pagina showconfig e vi a seguinte definição para o site website:

 

<site name="website" enableTracking="true" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/brands/clientname" startItem="/home" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="50MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="25MB" filteredItemsCacheSize="10MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" cacheRenderingParameters="true" renderingParametersCacheSize="10MB" language="en" patch:source="Client.Brands.ClientName.Project.ClientName.config" itemwebapi.mode="Off" itemwebapi.access="ReadOnly" itemwebapi.allowanonymousaccess="false" enableItemLanguageFallback="false" enableFieldLanguageFallback="false" hostname="clientname.dev.local|local.clientname.com"/>

Conforme respondido aqui, eu precisei mudar o atributo hostname para usar a letra maiúscula N assim: hostName, porque os atributos das definições dos sites respeitam maiúsculo e minúsculo. Apos realizar essa mudança ele começou a carregar corretamente o valor do atributo hostname. Você pode ler mais sobre os atributos das definições de sites aqui

 

Sitecore 8: Hostname not being retrieved for the website definition. What could be wrong?

Recently I have been working on a Sitecore project and I was building a list of sites dynamically like this:

sites = SiteManager.GetSites().Select(s => new SiteInfo(s.Properties)).ToList();

The problem is that at debug mode I could see the values of the hostname attributes for the website definition properly set. But it would not populate the property with the value from the config. in other words the value would return blank for the hostname attribute.

I checked the showconfig page and got the following definition:

<site name="website" enableTracking="true" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/brands/clientname" startItem="/home" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="50MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="25MB" filteredItemsCacheSize="10MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" cacheRenderingParameters="true" renderingParametersCacheSize="10MB" language="en" patch:source="Client.Brands.ClientName.Project.ClientName.config" itemwebapi.mode="Off" itemwebapi.access="ReadOnly" itemwebapi.allowanonymousaccess="false" enableItemLanguageFallback="false" enableFieldLanguageFallback="false" hostname="clientname.dev.local|local.clientname.com"/>

As pointed out here (thanks @MarasM) I needed to change the hostname to use the capital N as in hostName because the site attributes are case sensitive. Changing it made it to start working so I decided to post this to help out anyone who faces this issue.

You can read more about site attributes here.

Problemas ao sincronizar o Unicorn. Qual era e o como resolvi

Recentemente eu trabalhei em um projeto e eu tive um problema ao tentar sincronizar o Unicorn. Por conta disso resolvi escrever este post para compartilhar o aprendizado.

O Problema:

Eu tentava sincronizar, reserializar as minhas configurações mas sempre aparecia esta tela:

screen1

As definições das minhas configurações eram as seguintes(note a parte em negrito):

<configuration xmlns:patch=”http://www.sitecore.net/xmlconfig/”&gt;

<sitecore>

<unicorn>

<configurations>

<configuration name=”Feature.Navigation” description=”Feature Navigation” dependencies=”Foundation.Serialization” patch:after=”configuration[@name=’Foundation.Serialization’]”>

<targetDataStore physicalRootPath=”$(sourceFolder)\feature\navigation\serialization” type=”Rainbow.Storage.SerializationFileSystemDataStore, Rainbow” useDataCache=”false” singleInstance=”true” />

<predicate type=”Unicorn.Predicates.SerializationPresetPredicate, Unicorn” singleInstance=”true”>

<include name=”Feature.Navigation.Templates” database=”master” path=”/sitecore/templates/Feature/Navigation” />

<include name=”Feature.Navigation.Renderings” database=”master” path=”/sitecore/layout/renderings/Feature/Navigation” />

 <include name=”Feature.Navigation.Media” database=”master” path=”/sitecore/media library/Feature/Navigation” />

</predicate>

<roleDataStore type=”Unicorn.Roles.Data.FilesystemRoleDataStore, Unicorn.Roles” physicalRootPath=”$(sourceFolder)\feature\navigation\serialization\Feature.Navigation.Roles” singleInstance=”true”/>

<rolePredicate type=”Unicorn.Roles.RolePredicates.ConfigurationRolePredicate, Unicorn.Roles” singleInstance=”true”>

<include domain=”modules” pattern=”^Feature Navigation .*$” />

</rolePredicate>

</configuration>

</configurations>

</unicorn>

</sitecore>

</configuration>

A Solução

Após revisar as configurações, notei que elas pareciam estar corretas então eu revisei todos os includes definidos nas configurações. Ao fazer esse exercício eu percebi que na seção Media, havia um caminho que não existia na arvoré de conteúdo do Sitecore. Estava faltando a pasta Navigation no caminho sitecore/media library/Feature.

Quando eu criei esta pasta o Unicorn passou a sincronizar normalmente. Em outras palavras, se você não estiver conseguindo sincronizar, revise as suas configurações e os caminhos definidos no Sitecore, e veja se eles todos estão corretos.

Talvez isso seja útil e evite perdas de tempos no futuro para alguém 🙂

screen

Sync issue with Unicorn. What was it and how I fixed it.

Recently I have worked on a project and I had an issue syncing Unicorn and I decided to write this post to share what was it and how I fixed it.

The Problem:

I tried syncing, reserializing Unicorn but I would still keet getting this screen:

screen1

This is what my configuration looked like(Note the bolded section):

<configuration xmlns:patch=”http://www.sitecore.net/xmlconfig/”&gt;

<sitecore>

<unicorn>

<configurations>

<configuration name=”Feature.Navigation” description=”Feature Navigation” dependencies=”Foundation.Serialization” patch:after=”configuration[@name=’Foundation.Serialization’]”>

<targetDataStore physicalRootPath=”$(sourceFolder)\feature\navigation\serialization” type=”Rainbow.Storage.SerializationFileSystemDataStore, Rainbow” useDataCache=”false” singleInstance=”true” />

<predicate type=”Unicorn.Predicates.SerializationPresetPredicate, Unicorn” singleInstance=”true”>

<include name=”Feature.Navigation.Templates” database=”master” path=”/sitecore/templates/Feature/Navigation” />

<include name=”Feature.Navigation.Renderings” database=”master” path=”/sitecore/layout/renderings/Feature/Navigation” />

 <include name=”Feature.Navigation.Media” database=”master” path=”/sitecore/media library/Feature/Navigation” />

</predicate>

<roleDataStore type=”Unicorn.Roles.Data.FilesystemRoleDataStore, Unicorn.Roles” physicalRootPath=”$(sourceFolder)\feature\navigation\serialization\Feature.Navigation.Roles” singleInstance=”true”/>

<rolePredicate type=”Unicorn.Roles.RolePredicates.ConfigurationRolePredicate, Unicorn.Roles” singleInstance=”true”>

<include domain=”modules” pattern=”^Feature Navigation .*$” />

</rolePredicate>

</configuration>

</configurations>

</unicorn>

</sitecore>

</configuration>

The Solution

So after reviewing the configurations and validating that they seemed to be correct, I reviewed all the include mappins. So when I got to the Media section I noticed that the path defined on the configuration file didn’t exist within Sitecore’s content tree. It turned out that it was missing the Navigation folder under /sitecore/media library/Feature.

When I created it, unicorn started syncing properly again.  In other words, if you are not being able to sync double check if your configs and the paths underneath Sitecore  are all valid. This was the problem in my case. Hopefully this will save anyone sometime in the future.

screen