The Spry toolset in the latest versions of Dreamweaver are a great set of features, especially the Spry Dataset for integrating xml files such as RSS data feeds. Customisation of certain functionality however, I’ve found tricky to implement at times. Here’s a few Spry tips that I’ve found useful when integrating xml data in websites.
One such seemingly simple task is being able to limit the number of rows displayed in a Spry repeat region from a Spry XML dataset. I found the below solution hidden in the Adobe Spry documentation. To limit the rows from an xml feed, locate the Spry dataset variable e.g:
var ds1 = new Spry.Data.XMLDataSet("feed.xml", "rss/item");
Then add [position() < X] to the xml node element, where X is the number of rows you want to display. For example to limit the rows to 10, use the following:
var ds1 = new Spry.Data.XMLDataSet("feed.xml", "rss/item[position() < 10]");
Firstly add the function below in the head tag:
Where '0' is the character position to start trimming and '100' is how many characters you want to limit the field by. Next, replace the field name in the code generated by the Spry xml dataset to reference the character limiting function. For example the line:
Adobe prevents using cross-domain xml files for security reasons, to protect any potential malicious code from finding it's way into your site. There's a number of reasons you may need to use external feeds, for example if you have multiple domains with data on the sites drawn from a single source.
I initially purchased an extension which I thought would do the trick but I had the security problems enabling the external feed to display in anything but the Chrome browser. Then I found this cross domain solution (for PHP) - full credit to Andy at the Pandahaus for this one.
Simply paste the code block from the link above into a new php file and reference the file from the main Spry dataset definition, i.e:
var ds1 = new Spry.Data.XMLDataSet("feed.php", "rss/item");