plonediazo

How to move a portlet into content's #content area?


I would like to modify the content on the fly so I can later feed the modified version into my theme's content slot. The usecase is positioning the calendar portlet inside a collective.cover row/column/cell.

Here's what I tried:

<replace css:content="#content .row:nth-child(2) .cell:nth-child(2) .tile.tile-edge">

  <!-- These work (meaning levels above current selection CAN be copied) -->
  <xsl:copy-of select="." />
  <xsl:copy-of select="../.." />
  <xsl:copy-of select="/" />

  <!-- However, neither of these do -->
  <xsl:copy-of css:select=".portletCalendar:first-child" />
  <xsl:copy-of select="//div[contains(concat(' ', normalize-space(@class), ' '), ' portletCalendar ')]" />
  <xsl:copy-of select="//div[@id='portal-personaltools']" />

</replace>

Solution

  • It may be that the only problem you were having was relying on Diazo's facility for translating css selectors in XSL commands. It only works if the target is the currently selected node or a child of it. So, replace it with an XPath selector:

    <!-- replace one part of content with another -->
    <replace css:content="#content .row:nth-child(2) .cell:nth-child(2) .tile.tile-edge">
      <xsl:copy-of select="//dl[@class='portlet portletCalendar']" />
      <xsl:apply-templates mode="raw" />
    </replace>
    
    <!-- make sure it doesn't show up in two places -->
    <drop content="//dl[@class='portlet portletCalendar']" />