Hi Mike, Freemarker templates are bit different then JSPs so there is no notion of pageContext, rather the application processing the template can provide own set of implicit objects.
Here's the list of objects provided by Magnolia to any freemarker template: http://documentation.magnolia-cms.com/releases/4-0-1/templating.html and few extra objects to STK freemarker templates: http://documentation.magnolia-cms.com/templating/stk/templating.html#STKspecificContextObjects as for your problem simple ${ctx.contextPath} would give you what you are looking for. However I suggest you look at STK and how it handles css loading via Theme mechanism and models assigned to templates. This can make loading css files as simple as [#list model.site.theme.cssFiles as cssFile] <link rel="stylesheet" type="text/css" href="${cssFile.link}" media="${cssFile.media}" /> [/#list] while letting you to configure the css files and their content via Magnolia's AdminCentral. (the above excerpt of the code is from Templating Kit/Templates:/templatingKit/templates/global/htmlHeader HTH, Jan On May 18, 2011, at 6:34 PM, Magnolia Forums (on behalf of Mike Herzog) wrote: > > Hi Magnolians, > > I want to create my own custom (freemarker-) template. I created a new > template file and set up > modules/templating/templates/<myProject>/<myTemplate> to use it. Next I > created a website based using that template. This works as expected. > > However, now I want to add a style sheet (.css) file to my template. When I > add [code]<link rel="stylesheet" type="text/css" media="all" > href="${pageContext.request.contextPath}/docroot/<myProject>/css/main.css" > />[/code] to the html head section of my template, I get an FreeMarker > template error: > [quote]Expression pageContext is undefined on line 8, column 68 in > templates/<myProject>/templates/homepage.ftl. > The problematic instruction: > ---------- > ==> ${pageContext.request.contextPath} [on line 8, column 66 in > templates/<myProject>/templates/homepage.ftl] > ----------[/quote] > > Why is the pageContext not set? > > How can I use my style sheet in my template? > > Thanks, > Mike > [;-) > > -- > Context is everything: > http://forum.magnolia-cms.com/forum/thread.html?threadId=0bc436ee-d5ab-4b9d-9716-94b50f9b6cf9 > > > ---------------------------------------------------------------- > For list details see > http://www.magnolia-cms.com/home/community/mailing-lists.html > To unsubscribe, E-mail to: <[email protected]> > ---------------------------------------------------------------- ---------------------------------------------------------------- For list details see http://www.magnolia-cms.com/home/community/mailing-lists.html To unsubscribe, E-mail to: <[email protected]> ----------------------------------------------------------------
