Adicionando novos elementos na estrutura de componentes do BVS-Site 4

De Wiki REDDES

Objetivos

Disponibilizar novos campos (elementos) para tipos de componentes do BVS-Site 4.

Procedimentos

1. Adicionar no adm.xml do site os novos campos nos itens com id new_portal e change_portal

2. Alterar no save.xsl da pasta xsl/adm o template que grava o item


        <xsl:template match="item" mode="cgi">
                <xsl:choose>
                        <xsl:when test="$cgi/page = 'about'">
                                <xsl:element name="item">
                                        <xsl:apply-templates select="id" mode="cgi"/>
                                        <xsl:apply-templates select="available" mode="cgi"/>
                                        <xsl:apply-templates select="href" mode="cgi"/>
                                        <xsl:apply-templates select="img" mode="cgi"/>
                                        <xsl:apply-templates select="name/text()"/>
                                        <xsl:apply-templates select="description" mode="cgi"/>
                                        <xsl:apply-templates select="portal" mode="cgi"/>
                                        <xsl:apply-templates select="item" mode="cgi"/>
                                </xsl:element>
                        </xsl:when>
                        <xsl:otherwise>
                                <xsl:element name="item">
                                        <xsl:apply-templates select="id" mode="cgi"/>
                                        <xsl:apply-templates select="available" mode="cgi"/>
                                        <xsl:apply-templates select="href" mode="cgi"/>
                                        <xsl:apply-templates select="img" mode="cgi"/>
                                        <xsl:apply-templates select="file" mode="cgi"/>
                                        <xsl:apply-templates select="adm" mode="cgi"/>
                                        <xsl:apply-templates select="name/text()"/>
                                        <!-- novos campos a serem gravados -->
                                        <xsl:apply-templates select="description" mode="cgi"/>
                                        <xsl:apply-templates select="portal" mode="cgi"/>
                                        <!-- /novos campos a serem gravados -->
                                        <xsl:apply-templates select="item" mode="cgi"/>
                                </xsl:element>
                        </xsl:otherwise>
                </xsl:choose>
        </xsl:template>

3. Alterar o tree.xsl para carregar os novos conteúdos gravados no XML para o JS que monta a página do admin


        <xsl:template match="item" mode="array">
                "<xsl:element name="available"><xsl:apply-templates select="@available" mode="escape_quotes_js"/></xsl:element>" +
                "<xsl:element name="id"><xsl:apply-templates select="@id" mode="escape_quotes_js"/></xsl:element>" +
                "<xsl:element name="name"><xsl:apply-templates select="text()" mode="escape_quotes_js"/></xsl:element>" +
                "<xsl:element name="img"><xsl:apply-templates select="@img" mode="escape_quotes_js"/></xsl:element>" +
                "<xsl:element name="href"><xsl:apply-templates select="@href" mode="escape_quotes_js"/></xsl:element>" +
                "<xsl:element name="description"><xsl:apply-templates select="description" mode="copy-js"/><xsl:value-of select="' '"/></xsl:element>" +
                "<xsl:element name="portal"><xsl:apply-templates select="portal" mode="copy-js"/><xsl:value-of select="' '"/></xsl:element>",
                <xsl:apply-templates select="item" mode="array"/>
        </xsl:template>

4. Alterar na parte pública para adicionar level no componente portal do site portalList.xsl


<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.3" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:include href="xsl/public/components/default/portalList.xsl"/>

        <xsl:template match="portal//item[@href != '' and @img]">
                <li><a href="{@href}" target="_blank"><img src="{@img}" alt="{text()}" /><span><xsl:apply-templates select="text()" /></span></a></li>
        </xsl:template>

        <xsl:template match="portal/item/item[not(@href)]">
                <li>
                        <a href="../php/level.php?lang={$lang}&component={$id}&item={@id}"><span><xsl:apply-templates select="text()" /></span></a>
                </li>
        </xsl:template>

        <xsl:template match="portal/item/item[not(@href) and @img]">
                <li>
                        <a href="../php/level.php?lang={$lang}&component={$id}&item={@id}"><img src="{@img}" alt="{text()}" /><span><xsl:apply-templates select="text()" /></span></a>
                </li>
        </xsl:template>
</xsl:stylesheet>


Herramientas personales