Shelan,

I will check the wrapper, but I think the #parse is a bit more
involved.  (There is some great inheritance on this stuff!).

If you check RollerResourceLoader & ThemeResourceLoader there is a
method getResourceStream( String name ) which is called by the
velocity #parse mechanism and only can take a single string.

In these two getReasourceStream() methods the templates are loaded,
for custom themes the db (RollerResourceLoader) or shared themes the
ThemeManager (ThemeResourceLoader)

ie

WeblogTemplate page =

WebloggerFactory.getWeblogger().getWeblogManager().getPage(name);

ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
            Theme theme = themeMgr.getTheme(split[0]);
            ThemeTemplate template = theme.getTemplateByName(split[1]);

I think here what we may need here is to pass in the type in the
template name similar to the way the shared templates names are
handled <theme>:<template>

eg

from:
#macro(includeTemplate $weblog $pageName)
    #set($pageArg = $weblog.getPageByName($pageName))
    #if ($pageArg)
       #parse($pageArg.id)
    #end
#end
to:
#macro(includeTemplate $weblog $pageName)
  #set($pageArg = $weblog.getPageByName($pageName))
  #set($pageId = $pageArg.id+':'+$model.type)
  #if ($pageArg)
     #parse($pageId)
  #end
#end

then in the getReasourceStream() extract the type and then load the
code from via the statement:

template = RendererManager.prepareTemplate(template, type);

To test, if you remove the db access for the template field (jpa) it
currently does not work as is picking up what is currently in the
field.

Cheers Greg.

On 20 September 2011 04:37, shelan Perera <[email protected]> wrote:
> Hi Greg,
>
> In WeblogWrapper Class ,
>
> public ThemeTemplateWrapper getPageByName(String name)
>            throws WebloggerException {
>       ThemeTemplate templateToWrap =
> this.pojo.getTheme().getTemplateByName(name);
>
> // This will prepare the template with the type.
>        prepareTemplate(templateToWrap, type);
>        return ThemeTemplateWrapper.wrap(templateToWrap);
>    }
>
> we are preparing the template before returning according to the "type"
> parameter. In the implementation we did not change the existing velocity
> method so used the default ("standard") at that time.
>
> What we need to do to rectify is deprecating existing getPageByName(String
> name) and introduce getPageByName(String name, String type); I think in that
> case we need to change the method name to a proper one since get page by
> name and type.
>
> We can easily introduce these changes with minor changes.
>
> Thanks
>
> On Sun, Sep 18, 2011 at 10:43 PM, Greg Huber <[email protected]> wrote:
>
>> Dave,
>>
>> I was looking at the code changes and was wondering how
>> #includeTemplate(..) macro was going to be implemented.  During the
>> parse process it seems to call RollerResourceLoader
>> getResourceStream(String name) and in turn looks up the page template
>> (but now not the code).  It does not look like there is an easy way to
>> get to the render type set in the PageServlet.  Will see if I can find
>> an easy solution.
>>
>> Cheers Greg.
>>
>
>
>
> --
> Shelan Perera
>
> Home: http://www.shelan.org
> Blog   : http://www.shelanlk.com
> Twitter: shelan
> skype  :shelan.perera
> gtalk   :shelanrc
>
>  I am the master of my fate:
>  I am the captain of my soul.
>         *invictus*
>

Reply via email to