I’m migrating an Umbraco 8 site to Umbraco 13 using usync migrate. Everything looks to have converted well but now I’m in the code trying to knit it all back together.
I am trying to recreate the master template but I’m struggling with model clashes using ModelsBuilder(SourceCodeAuto).
I have two root nodes, one is home and one is global which holds all the sitewide variables and controls like header scripts. Under the global node is the header and footer content nodes which I’m struggling to access consistently.
I currently can either get the global content or the footer content but not both together. See my partial view below:
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.Footer>;
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
@using Umbraco.Cms.Core;
@using Umbraco.Cms.Core.Models.PublishedContent;
@using Umbraco.Cms.Core.Routing;
@using Umbraco.Extensions;
@{
var globalSettings = ViewBag.Settings as Settings;
}
<footer class="footer" id="footer">
<div class="container">
<div class="inner">
@if (!string.IsNullOrWhiteSpace(globalSettings.FacebookProfile) || !string.IsNullOrWhiteSpace(globalSettings.TwitterProfile) || !string.IsNullOrWhiteSpace(globalSettings.LinkedInProfile) || !string.IsNullOrWhiteSpace(globalSettings.InstagramProfile))
{
<div class="social-links">
@if (!string.IsNullOrWhiteSpace(globalSettings.FacebookProfile))
{
<a href="@globalSettings.FacebookProfile" target="_blank" aria-label="Link to Facebook page" class="btn fill ga_facebook_visit">
<span class="sr-only">Link opens in new tab</span>
<svg aria-hidden="true" class="icon">
<use xlink:href="/images/icons.svg#icon-facebook" />
</svg>
Visit us on Facebook
</a>
}
@if (!string.IsNullOrWhiteSpace(globalSettings.TwitterProfile))
{
var twitter = !string.IsNullOrWhiteSpace(globalSettings.TwitterUsername) ? globalSettings.TwitterUsername : "on Twitter";
<a href="@globalSettings.TwitterProfile" target="_blank" aria-label="Link to Twitter profile" class="btn fill ga_twitter_follow">
<span class="sr-only">Link opens in new tab</span>
<svg aria-hidden="true" class="icon">
<use xlink:href="/images/icons.svg#icon-twitter" />
</svg>
Follow us @twitter
</a>
}
@if (!string.IsNullOrWhiteSpace(globalSettings.LinkedInProfile))
{
<a href="@globalSettings.LinkedInProfile" target="_blank" aria-label="Link to LinkedIn page" class="btn fill linked-in ga_linkedin_visit">
<span class="sr-only">Link opens in new tab</span>
<svg aria-hidden="true" class="icon">
<use xlink:href="/images/icons.svg#icon-linkedin" />
</svg>
Visit us on LinkedIn
</a>
}
@if (!string.IsNullOrWhiteSpace(globalSettings.InstagramProfile))
{
var instagram = !string.IsNullOrWhiteSpace(globalSettings.InstagramUsername) ? globalSettings.InstagramUsername : "on Instagram";
<a href="@globalSettings.InstagramProfile" target="_blank" aria-label="Link to Instagram profile"
class="btn fill ga_instagram_visit">
<span class="sr-only">Link opens in new tab</span>
<svg aria-hidden="true" class="icon">
<use xlink:href="/images/icons.svg#icon-instagram" />
</svg>
Visit us @instagram
</a>
}
</div>
}
<div class="footer-nav">
<!--if (Model.Navigation != null && Model.Navigation.Any())
{
<ul>
foreach (var navLink in Model.Navigation)
{
<li><a href="navLink.Url" target="navLink.Target" aria-label="Link to navLink.Name">navLink.Name</a></li>
}
</ul>
}
if (Model.SubNav != null && Model.SubNav.Any())
{
<ul>
foreach (var navLink in Model.SubNav)
{
<li><a href="navLink.Url" target="navLink.Target" aria-label="Link to navLink.Name">navLink.Name</a></li>
}
</ul>
}-->
</div>
</div>
<div class="footer-bottom">
@if (!string.IsNullOrEmpty(Model.CopyrightText))
{
<p>Copyright © @DateTime.Now.Year @Model.CopyrightText</p>
}else{
<p>Copyright © @DateTime.Now.Year</p>
}
@if (Model != null)
{
<p>Model is not null</p>
<p>CopyrightText: @Model.CopyrightText ?? "No value or null"</p>
}
else
{
<p>Model is null</p>
}
</div>
</div>
</footer>
I’ve tried everything I can think of, different inheritance, adding the footer node more specifically etc… but I think I am just not experienced enough to identify the issue.