Skip to content

Instantly share code, notes, and snippets.

@Adniel
Created March 22, 2014 16:47
Show Gist options
  • Save Adniel/9710238 to your computer and use it in GitHub Desktop.
Save Adniel/9710238 to your computer and use it in GitHub Desktop.
Fix columns in collective.cover to bootstrap3
<?xml version="1.0" encoding="UTF-8"?>
<rules
xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- fix cover -->
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-1')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-1</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-2') or contains(@class, 'width-3')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-2</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-4') or contains(@class, 'width-5')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-3</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-6')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-4</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-7')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-5</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-8') or contains(@class, 'width-9')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-6</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-8') or contains(@class, 'width-9')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-6</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-10')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-7</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-11')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-8</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-12') or contains(@class, 'width-13')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-9</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-14')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-10</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-15')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-11</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-16')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-12</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[@id='editable-blocks']/div[1]/div[1]">
<xsl:copy>
<xsl:attribute name="class">col-sm-7 type-choice</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<replace content="body[contains(@class, 'portaltype-collective-cover-content')]//div[@id='editable-blocks']/div[1]/div[2]">
<xsl:copy>
<xsl:attribute name="class">col-sm-5 creator-highlighted</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</replace>
<!--Identity template copies content forward -->
<replace content="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</replace>
</rules>
<rules
xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="cover-to-bootstrap3.xml" />
<!-- The rest of your rules comes below -->
</rules>
@Adniel
Copy link
Author

Adniel commented Mar 22, 2014

"stolen" from numahell (https://gist.github.com/numahell, thank you). Changed xsl:template match to replace to enable xi:include since template match can not be nestled, because I wanted it to be outside my very clean and simple rules.xml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment