Hide exceptions when using Include / Excerp macro for pages with no read permission

Hello,

We are trying to setup a dynamic XWiki document which has public information as well as internal information. The internal information is being included and should only be visible if the user has read permissions on the source document.

In general it is working fine when using the include or excerp macro, however if the user has no read permission on the source document of the included document / section, there is an exception in a red error box (org.xwiki.rendering.macro.MacroExecutionException: Current user … doesn’t have view rights on document ).

Is there any workaround to just hide the content if the user has no read permission on the source?

Thanks!

Hi,

You could have a Velocity condition around your include macro call, see an example here (for edit rights, but you can adapt) and the reference documentation if needed.

Hope that helps!