Search

Hello,

I want to insert specific elements such as script and link to the head element on different pages. I don’t want to use all javascripts and stylesheets to all pages.

Is that possible?

Thanks in advance!

On the front end?

@czheng Exactly. In my case, I’m using the master.xsl template for all pages.

In your master template:

<xsl:apply-templates select="data" mode="assets"/>

In each page’s template:

<xsl:template match="data" mode="assets">
    <link rel="stylesheet" href="path-to-stylesheet" media="screen" type="text/css" />
</xsl:template>

I thought that were too hard to solve it. Simple and elegant solution. Thanks!

Just out of curiosity, Do you see another way to solve it?

@czheng I have to declare that template on all pages?

Do you see another way to solve it?

Nothing as simple, no.

I have to declare that template on all pages?

Only the pages that need special assets in the header.

I have to declare that template on all pages?

Only the pages that need special assets in the header.

For all the others, who don’t need custom header elements, you can create one in your master.xsl.

It works. Thanks for helping!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details