Ribbon missing from Publishing Pages


Today I was creating a web template but basing it on a Publishing site template. I used the BLANKINTERNETCONTAINER. When my site was created, I realized that the ribbon bar was missing. I thought maybe because I selected the BLANKINTERNETCONTAINER which is a starter site for an internet facing site. I thought maybe this was the reason why the ribbon bar was missing, because it was an intranet site and most users would be visitors and not be requiring the ribbon.

So I changed the Base Template to be using the CMSPUBLISHING template instead. Still the Ribbon Bar was missing. In case it was a problem with my Web Template I created an out the box publishing site, and I still had no Ribbon.

Apparently you can turn it on by click on the cog (Site Actions) and selecting Show Ribbon. Also note that the Edit link shows up too.

I have found out how SharePoint knows if the Ribbon bar needs to show for the user. It is all based on a Cookie.

To prove this open your publishing site in Chrome and open the developer toolbar (F12). Now click on the resource tab. Under Cookies click on your site.

In the picture above, you will see the name ConsoleVisible0b4b4030-2d96-4443-a578-1150dc145e40 and the value set to true. If you now hide the ribbon bar the value will now say false. Alternatively you could delete the Cookie from Chrome by right clicking on it and clicking Delete, and refresh the page.

I have also discovered that the Guid after the ConsoleVisible is the Site.ID guid.

Now to permanently leave the Ribbon bar on, there is an option in the Site Settings -> Look and Feel -> Navigation. This opens _layouts/15/AreaNavigationSettings.aspx. Right at the bottom of this page there is a section called “Show and Hide Ribbon” By click the Yes option and then clicking OK, when you get back to your page you will see that the ribbon bar is there. And you can no longer Hide and Show the ribbon bar. It is permanently there. Also it doesn’t matter what your cookie is set at, the ribbon bar will always display.

It appears if you check the root site web properties using powershell an entry is added called __DisplayShowHideRibbonActionId. If this is set to true the ribbon bar is hidden, and can be toggled by the user. If this is set to false the ribbon bar is showing, and the user doesn’t have the choice to show or hide.

So I have learnt that I can enable it or disable it via cookie, web property. But how do I ensure that I can activate it in a web template? Well I was hoping that there was a property in a navigation type feature in the onet.xml file I could add. Unfortunately not. So the only option I have left is to create a web feature and add this feature to my onet.xml file. This option should also work for SharePoint 365.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
 <PropertyBag ParentType="Web" RootWebOnly="True">
 <Property Name="__DisplayShowHideRibbonActionId" Value="false" Type="string" />
 </PropertyBag>
</Elements>

Another option would be a feature that adds a javascript file to the masterpage that checks if the rootweb properties contains __DisplayShowHideRibbonActionId and either add/update/leave it accordingly. Although this would have overhead for every user who hits the page.

Advertisements