ServerName in Velocity

14 views
Skip to first unread message

Rafael Morales Gamboa

unread,
Mar 25, 2022, 11:34:33 PM3/25/22
to Sakai Development
Hello,

I have edited header-snippet.vm in sakai/portal/portal-render-engine-mpl/impl/src/webapp/vm/morpheus/snippets, replacing

<span class="Mrphs-headerLogo--institution"></span>

by 

<a class="Mrphs-headerLogo--institution" href="https://${serverName}"></a>

I have done that inspired by the code 

<li><a href="mailto:${alias.getId()}@${serverName}" title="$tlang.getString("lis.sendmailto") ${alias.getId()}@${serverName}">${alias.getId()}@${serverName}</a></li>

in sakai/mailarchive/mailarchive-tool/tool/src/webapp/vm/mailarchive/chef_mailbox-List.vm

However, in my code ${serverName} is not replaced by the value of that property in sakai.properties. Is there anything else I need to do?

Regards,
Rafael

Miguel Pellicer

unread,
Mar 29, 2022, 4:15:37 AM3/29/22
to Rafael Morales Gamboa, Sakai Development

Hey Rafael!

You're mixing sakai.properties with velocity context attributes, unless you put in the context an attribute called "serverName" it will never be accessible through the VM template.

Here's an example of what you're missing:

https://github.com/sakaiproject/sakai/blob/master/portal/portal-impl/impl/src/java/org/sakaiproject/portal/charon/SkinnableCharonPortal.java#L1961

If you want to display the "serverName" value in the template, you have to put it in the context in the method that builds the context of your template.

rcontext.put("serverName", ServerConfigurationService.getString("serverName"));

Miguel

--
You received this message because you are subscribed to the Google Groups "Sakai Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sakai-dev+...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/sakai-dev/a2c1dc00-cd3b-49e0-84fa-3321f4c14c2en%40apereo.org.
-- 
-----------------------------------------------
Miguel Pellicer
CTO at EDF

Website: https://www.edf.global
LinkedIn: https://www.linkedin.com/in/mpellicer-edf
Office Phone: +34 - 96 381 35 75
Request a meeting here: https://calendly.com/mpellicer
-----------------------------------------------
Reply all
Reply to author
Forward
0 new messages