![]() |
|
sfXSLTViewPlugin - 0.1.2symfony xslt view plugin |
|
![]() |
3
users
Sign-in
to change your status |
A plugin to provide XSLT as a templating system |
| Name | Status | |
|---|---|---|
|
|
lead | ku.oc.rebotcoetihw <<ta>> sdrawj |
Copyright (c) 2007 John Wards White October Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| Version | License | API | Released |
|---|---|---|---|
| 0.1.2beta | MIT license | 0.1.2beta | 11/12/2007 |
| 0.1.1beta | MIT license | 0.1.1beta | 27/11/2007 |
| 0.1.0beta | MIT license | 0.1.0beta | 27/11/2007 |
| 0.0.5alpha | MIT license | 0.0.5alpha | 21/09/2007 |
| 0.0.4alpha | MIT license | 0.0.3alpha | 21/09/2007 |
| 0.0.3alpha | MIT license | 0.0.3alpha | 14/09/2007 |
| 0.0.2alpha | MIT license | 0.0.2alpha | 12/09/2007 |
| 0.0.1alpha | MIT license | 0.0.1alpha | 03/09/2007 |
This plugin is now being used in 3 client sites by [http://www.whiteoctober.co.uk] and is now in a more stable state.
Please use this forum post to ask questions: http://www.symfony-project.org/forum/index.php/t/8506/
It now offers support for components.
If you have set components up they are avaliable by selecting /XML/components/componentname in XSLt.
<xsl:value-of select="/XML/components/crumb" disable-output-escaping="yes"/>
The plugin also supports xsltCache which is a plugin developed by the NY Times [http://code.nytimes.com/projects/xslcache]
You assign variables in the same way you do normally using symfony. It uses the names of these variables as the node names. These are case sensitive.
It also senses if the object has a toArray method and creates a multi dimensional array based on this.
If you pass an array which keys are numeric is persumes that these are multiples of the parent node.
$this->sheeps = array("bah", "bahhh", "bahhh", "mooo");
<sheeps>
<sheep>bah</sheep>
<sheep>bahhh</sheep>
<sheep>bahhh</sheep>
<sheep>mooo</sheep>
</sheeps>
In the example files the "Success" template is looking for the layout.xsl file in the same directory. In all of our applications we put in in the "normal" layout directory.
So to include a layout.xsl which is in your apps/application/template folder from your apps/application/modules/amodule/template/indexSuccess.xsl you need this at the top:
<xsl:include href="../../../templates/layout.xsl"/>
symfony plugin-install http://plugins.symfony-project.com/sfXLTViewPlugin
Create a module.yml either in your project config directory or in your apps config directory that contains the following:
all:
view_class: sfXSLT
When you are in symfony "debug mode" (you have DEBUG set in your controller) if you add dumpXML=1 to any query string you will get a dump of the current XML returned to you.
If you set a sfPropelPager up like the backend generator makes for you, it will sense this for you and show you the result set and the paging information. Use the dumpXML=1 flag to see the resulting xml.
$this->groups = new sfPropelPager('sfGuardGroup', 20);
$c = new Criteria();
$this->addSortCriteria($c);
$this->addFiltersCriteria($c);
$this->groups->setCriteria($c);
$this->groups->setPage($this->getRequestParameter('page', 1));
$this->groups->setPeerMethod('doSelect');
$this->groups->setPeerCountMethod("doCount");
$this->groups->init();
<groups>
<group>
<id>1</id>
<name>admin</name>
<description>foo</description>
</group>
</groups>
Propel handly provides us with methods to "get" foriegn propel models. To recursivly get these into your xml is useful but if enabled by default could cause recursive nightmares.
If you want this feature you can turn it on or off on a per model basis.
Add the following code to any propel class, I am using a made up sfGuardGroupProfile class here..
/**
* Subclass for representing a row from the 'sf_guard_group_profile' table.
*
* @package lib.model
*/
class sfGuardGroupProfile extends BasesfGuardGroupProfile
{
public $XSLT_LOAD_FOREIGN = false;
public function getLoadForeign(){
return $this->XSLT_LOAD_FOREIGN;
}
public function setLoadForeign($v){
$this->XSLT_LOAD_FOREIGN=$v;
}
}
So in your action you could have the following:
$this->profile = sfGuardGroupProfilePeer::retrieveByPK(1);
$this->profile->setLoadForeign(true);
My example table has two foriegn tables that define the type and link back to the sfGuardGroup table. the resulting XML looks like this:
<profile>
<id>1</id>
<sf_guard_group_id>2</sf_guard_group_id>
<country_id>GB</country_id>
<type_id>1</type_id>
<pledge>Foo blah</pledge>
<uuid/>
<version>0</version>
<sfGuardGroup>
<id>2</id>
<name>Testing</name>
<description>test</description>
</sfGuardGroup>
<sfGuardGroupType>
<id>1</id>
<name>Open</name>
<created_at>2007-12-07 17:34:28</created_at>
<updated_at>2007-12-07 17:34:28</updated_at>
<uuid/>
<version>0</version>
</sfGuardGroupType>
</profile>
You may have problems with default symfony templates. Currently only the 404 template exists. You can add your own if you wish.
