How to handle an error when page.context.user. does not exist
I'm getting an error on View My Profile page, which is likely coming from this code: <#if user.id == page.context.user.id>
My guess is that page.context.user.id or user.id doesn't exist, so it throws an error. How do I handle that error in a conditional, so that instead of breaking, it just returns false, such as:
<#if user.id?? && page.context.user.id??>
<#if user.id == page.context.user.id> <#-- Only show Kudos tab on your own profile page -->
//stuff here
</#if>
</#if>
Thanks! Here's the whole code:
<#-- Add links -->
<ul class="profile-tabs">
<li class="tab-activity">
<a href="/t5/user/viewprofilepage/user-id/${page.context.user.id}/tab/activity">${text.format('general.Posts')}</a>
</li>
<#if user.id?? && page.context.user.id??>
<#if user.id == page.context.user.id> <#-- Only show Kudos tab on your own profile page -->
<li class="tab-votes">
<a href="/t5/kudos/mobilemykudospage">${text.format('text.UserRankNodeEditor.kudos.title')}</a>
</li>
</#if>
</#if>
<li class="tab-bio">
<a href="/t5/user/viewprofilepage/user-id/${page.context.user.id}/tab/bio">${text.format('taplet.commonComponents.nodeDescription.title')}</a>
</li>
</ul>
- Can you try:
page.context.user?? && page.context.user.id??