I have implemented paging into a client website but would like to reduce the amount of duplicated XSLT. The idea goes like this on the paging macro I have a property that accepts a string this string is the name of the XSLT file to import. The import sends the node as a parameter and then the imported file handles the specifics surrounding the formatting. Here is an example... It's not working and I am not 100% sure why, can someone assist me please.
You might be running into a problem that is detailed on the old forum. Basically, you'll have to save (in the Umbraco backend) the file that calls the import. So if you make any changes to format-video-list.xslt, you also have to save the xslt files that import this file.
I am have not yet tested this, but I'm assuming that you'll need to re-save ALL of the templates that call format-video-list.xslt because there is some compiling going on.
If you could report back to see if you'd need to re-save all of the calling files that would be great, thanks!
I did read the old post and re-saved all the files but I am still having an issue. I added the following code to the XSLT that was trying to import the formatting of each nodes contents and it returned 1 ID which was the source ID:
It seems you've missed an important piece of information regarding templates in XSLT: The match attribute specifies a pattern that should match a set of elements in the source XML, e.g. "data", "root/node" or "node[@nodeTypeAlias = 'Home']". When you specify "foo" as a match pattern, your template won't ever be instantiated because the Umbraco XML hasn't got a "foo" element (you're not using the 4.1beta2, are you?)
You can use a name attribute instead, and achieve the desired behaviour, but then you should use call-template instead of apply-templates on the calling end.
So let's try both - first using what I think you were aiming for:
Template in "format-video-list.xslt" (note I use the name attribute):
Importing XSLT to prevent duplication
I have implemented paging into a client website but would like to reduce the amount of duplicated XSLT. The idea goes like this on the paging macro I have a property that accepts a string this string is the name of the XSLT file to import. The import sends the node as a parameter and then the imported file handles the specifics surrounding the formatting. Here is an example... It's not working and I am not 100% sure why, can someone assist me please.
the template applied should be the template from the imported file. What am I missing I assume it's something simple?
Cheers, Daniel
Sorry forgot to add the imported files content.
You might be running into a problem that is detailed on the old forum. Basically, you'll have to save (in the Umbraco backend) the file that calls the import. So if you make any changes to format-video-list.xslt, you also have to save the xslt files that import this file.
I am have not yet tested this, but I'm assuming that you'll need to re-save ALL of the templates that call format-video-list.xslt because there is some compiling going on.
If you could report back to see if you'd need to re-save all of the calling files that would be great, thanks!
I did read the old post and re-saved all the files but I am still having an issue. I added the following code to the XSLT that was trying to import the formatting of each nodes contents and it returned 1 ID which was the source ID:
Any other ideas?
Okay cool, I have it now, you're sending the node's value to your template, instead of the node's content, try changing it to this:
Hi Daniel,
It seems you've missed an important piece of information regarding templates in XSLT: The match attribute specifies a pattern that should match a set of elements in the source XML, e.g. "data", "root/node" or "node[@nodeTypeAlias = 'Home']". When you specify "foo" as a match pattern, your template won't ever be instantiated because the Umbraco XML hasn't got a "foo" element (you're not using the 4.1beta2, are you?)
You can use a name attribute instead, and achieve the desired behaviour, but then you should use call-template instead of apply-templates on the calling end.
So let's try both - first using what I think you were aiming for:
Template in "format-video-list.xslt" (note I use the name attribute):
You should do this in the importing file:
Now, let's try it the other way:
Template in "format-video-list.xslt":
and then in the file that imports it, you can just do this:
/Chriztian
is working on a reply...