<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How to use a cms inside another cms</title><link>https://answers.axonivy.com/questions/2203/how-to-use-a-cms-inside-another-cms</link><description>&lt;p&gt;Hi all&lt;/p&gt;
&lt;p&gt;i'm trying to use cms inside another cms, i have a cms structure as below (i use insert cms marcro from ivy):
&lt;img alt="alt text" src="http://answers.axonivy.com/upfiles/Untitled_5BfUGGu.png"&gt;
so i create a Ivy project then try to get this cms inside html dialog, everything work fine. But if i get that cms in java/ivy script then the cms of second level is not evaluated correctly, it's still a marco, even i show this on screen.
&lt;img alt="alt text" src="http://answers.axonivy.com/upfiles/Untitled_6RLeLNd.png"&gt;
What is different of two ways here?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/2203/how-to-use-a-cms-inside-another-cms" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 23 Nov 2016 11:23:33 -0500</lastBuildDate><item><title>Answer by Reguel Wermelinger</title><link>https://answers.axonivy.com/questions/2203/how-to-use-a-cms-inside-another-cms/2216</link><description>&lt;p&gt;It's correct that embedded macro are only expanded in a JSP or JSF context. &lt;/p&gt;
&lt;p&gt;If you require embedded macro expansion in Java/IvyScript you can do that by using internal API. The following sample util expands embedded macros:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public class CmsExpanderUtil {

    public static String expand(String cmsTemplate)
    {
        IEmbeddedScriptExpander scriptExpander = EmbeddedScriptExpanderFactory.createExpander();
        try {
            return scriptExpander.expandEmbeddedScripts(cmsTemplate, 
                    Ivy.request().getContext(null), Ivy.request().getProject().getIvyScriptEngine(), false, 50);
        } catch (PersistencyException | EnvironmentNotAvailableException
                | IvyScriptException e) {
            return cmsTemplate;
        }
    }

}
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Wed, 23 Nov 2016 11:23:33 -0500</pubDate><guid>https://answers.axonivy.com/questions/2203/how-to-use-a-cms-inside-another-cms/2216</guid></item></channel></rss>