Search

I have a field that i would like to input the html direct into it, my xml shows the html normaly, but when i try to outpot the html it show the html tags like normal text.

Is there a way of outputing the html correctly from the fields?

can you post your xml and your xslt please?

I guess you're using <xsl:value-of select="element" /> where you should use <xsl:copy-of select="element" />.

I tryed to use copy of but no change, thats the part of the xml i´m having problems:

<entry id="7">
        <data time="12:21" weekday="7">2011-03-13</data>
        <imagem size="52 KB" path="/uploads" type="image/gif">
            <filename>desktop.gif</filename>
            <meta creation="2011-03-13T12:22:09-03:00" width="312" height="454" />
        </imagem>
        <conteudo-html mode="formatted">&lt;ul class=&quot;page_list&quot;&gt;
           &lt;li&gt;Formatação e instalação de sistemas operacionais&lt;/li&gt;
           &lt;li&gt;Remoção de virus, spywares e Malwares&lt;/li&gt;
           &lt;li&gt;Otimização de sistema&lt;/li&gt;
           &lt;li&gt;Upgrade de componentes ( memórias, HD´s )&lt;/li&gt;
           &lt;li&gt;Conserto e recuperação de fontes de alimentação&lt;/li&gt;
           &lt;li&gt;Reposição de partes e componentes&lt;/li&gt;
           &lt;li&gt;Manutenção periodica incluindo limpeza fisica&lt;/li&gt;          
       &lt;/ul&gt;
       &lt;div class=&quot;page_btn&quot;&gt;

            &lt;h3&gt;Formatação em até 24hrs&lt;/h3&gt;
            &lt;span class=&quot;big&quot;&gt;A mais ápida de Maringá&lt;/span&gt;&lt;br/&gt;
            &lt;a class=&quot;page_big_link&quot;&gt;clique e confira as condições &gt;&gt;&lt;/a&gt;
            &lt;span class=&quot;price&quot;&gt;
            R$55,55
            &lt;/span&gt;
       &lt;/div&gt;
       &lt;div class=&quot;page_btn&quot;&gt;
            &lt;h3&gt;PC TuneUP&lt;/h3&gt;
            &lt;ul class=&quot;small_list&quot;&gt;
                &lt;li&gt;Limpeza interna&lt;/li&gt;
                &lt;li&gt;Limpeza externa&lt;/li&gt;
                &lt;li&gt;Optimização do sistema&lt;/li&gt;
                &lt;li&gt;Verificação de hardware&lt;/li&gt;
                &lt;li&gt;Remoção de programas de 
                    teste ou não utilizados&lt;/li&gt;
            &lt;/ul&gt;
            &lt;span class=&quot;price&quot;&gt;
            R$39,90
            &lt;/span&gt;
       &lt;/div&gt;</conteudo-html>
        <titulo-da-pagina handle="desktops">Desktops</titulo-da-pagina>
    </entry>

And this is the xsl:

The html is encode in the xml, but how do i display it in the page as html and not as plain text?

I forgot to mention that this content is being pulled via ajax to a main page, don´t know if that has anything to do with the problem.

I guess you've enabled the "HTML-encode text" checkbox in your datasource, right? If yes, disable it.

Once i disable it, i lose all the html text output, the html is on the xml but in the site the html tags dont work:

<entry id="7">
            <data time="12:21" weekday="7">2011-03-13</data>
            <imagem size="52 KB" path="/uploads" type="image/gif">
                <filename>desktop.gif</filename>
                <meta creation="2011-03-13T12:22:09-03:00" width="312" height="454" />
            </imagem>
            <conteudo-html mode="formatted"><ul class="page_list">
               <li>Formatação e instalação de sistemas operacionais</li>
               <li>Remoção de virus, spywares e Malwares</li>
               <li>Otimização de sistema</li>
               <li>Upgrade de componentes ( memórias, HD´s )</li>
               <li>Conserto e recuperação de fontes de alimentação</li>
               <li>Reposição de partes e componentes</li>
               <li>Manutenção periodica incluindo limpeza fisica</li>          
           </ul>
           <div class="page_btn">

                <h3>Formatação em até 24hrs</h3>
                <span class="big">A mais ápida de Maringá</span><br/>
                <a class="page_big_link">clique e confira as condições >></a>
                <span class="price">
                R$55,55
                </span>
           </div>
           <div class="page_btn">
                <h3>PC TuneUP</h3>
                <ul class="small_list">
                    <li>Limpeza interna</li>
                    <li>Limpeza externa</li>
                    <li>Optimização do sistema</li>
                    <li>Verificação de hardware</li>
                    <li>Remoção de programas de 
                        teste ou não utilizados</li>
                </ul>
                <span class="price">
                R$39,90
                </span>
           </div></conteudo-html>
            <titulo-da-pagina handle="desktops">Desktops</titulo-da-pagina>
        </entry>

Any other ideas?

this is what i get in the front end :

desktop.gif Formatação e instalação de sistemas operacionais Remoção de virus, spywares e Malwares Otimização de sistema Upgrade de componentes ( memórias, HD´s ) Conserto e recuperação de fontes de alimentação Reposição de partes e componentes Manutenção periodica incluindo limpeza fisica Formatação em até 24hrs A mais ápida de Maringá clique e confira as condições >> R$55,55 PC TuneUP Limpeza interna Limpeza externa Optimização do sistema Verificação de hardware Remoção de programas de teste ou não utilizados R$39,90 Desktops 

I thought copy-of didn't have the disable-output-escaping option...

Seeing "desktop.gif" in your last message I think you're not only copying the field but the whole entry. Could you post all your XML and all your XSLT to pastie?

Looks to me like you have an apply-templates on an <entry> but no template match to catch it. As Nils says, we need to see all of your code to be sure.

OK here it is on pastie:

http://pastie.org/1672273

I think what nickdunn said makes sense, i´m new to xsl and could have forgot something, i looked at it, but just could not see it.

well i think i got it, i was using aply-templates to a entry like nickdunn said, and the template file a had created was not catching it, so i used the call-template method, included the template file, corrected the paths and everything came together.

It was about 6 hours into it, but finaly did it, but it was at least fun.

Now i have a question:

if i create a template utility, to be used on diferent pages, i have to use call-template correct? if i use apply-templates, this template has to be in the same file correct?

just so i get this right...

The first thing I was noticing was that you're using match and name in one template. I don't know if it's the source of your problem but you should remove the name attribute:

<xsl:template match="paginas/entry">

Oh and please don't go the named template-way just because it's easier. :-)

if i use apply-templates, this template has to be in the same file correct?

Definitely not.

Hi there,

If you want to use a template from another stylesheet/file you have to tell XSLT to import that other file by using the <xsl:import href="path/to/yourtemplate.xsl"/>just inside the stylesheet tag. Most of the time you would do this by creating a utility and importing that.

Once you have imported another stylesheet/file you can treat that stylesheet as though it is actually IN you current one. So both apply-templates and call-template will work with an imported file. The trick is you have to import/include or else it won't work.

But in this case you probably don't need to do that. I suggest putting your second template in the same stylesheet as your first one. As Phoque said you don't need to use the Named template method in this case.

So to quickly solve your original problem you would have something like this all in the one stylesheet (something like page.xsl) :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"
  doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  omit-xml-declaration="yes"
  encoding="UTF-8"
  indent="yes" />
<xsl:template match="data">
       <xsl:apply-templates match="paginas/entry"/>
</xsl:template>

<xsl:template match="paginas/entry" name="pagina">
  <div class="page_content">
     <div class="banner_info">

      <xsl:if test="$is-logged-in = 'true'">
        <xsl:text> &#8212; </xsl:text>
        <a class="editar" href="{$root}/symphony/publish/{../section/@handle}/edit/{@id}/">Edit</a>
      </xsl:if>
      <xsl:copy-of select="conteudo-html" />
    </div>
    <div class="banner_img">
        <img src="imagens/{imagem/filename}" alt=""  />      
    </div>
  </div>
</xsl:template>

</xsl:stylesheet>

Also a good trick for outputting the HTML (guessing this is from a Markdown field given that it's showing as 'formatted' in the XML?) if you tell XSLT to display all the elements like this.

<xsl:copy-of select="conteudo-html/*" />

The * tells XSLT to output EVERYTHING (ie all the node sets) in the selection. So just insert that into the code above and it should work.

First of all, timchesney thanks for taking the time to explain it so well, i actually played a few hours with that and i think a got it right. This site i´m bulding is using jquery load() to pull the other pages in, so i had a litlle bit of problem getting tha right too, but figure it out. When the site is done i will be posting a link here so you all can see it, and will be using symphony for my next projects. And i said in another post and i will say it again, symphony has the best community of all the cms´s out there, i used to use Joomla for my websites and for a few clients too, still like joomla, but with a community like this, and a cms as flexible and fun to work with like symphony, i think i found my new home. (maybe that sound a little girly, but thats all right).

Yeah, that's pretty girly. But you're welcome :)

I'm also experiencing the 'converted characters' issue and was hoping this thread would point me to a fix, but I must be missing something. I will try to provide all of the relevant info:

My section textarea for the malformed content is set to Markdown Extra with Smartypants. My datasource has "HTML-encode text" disabled.

  1. Content I've entered:

    `<div id="first"><strong id="second"">Here it is</strong>.</div>`
    
  2. My webpage output:

    <div id=&quot;first&quot;><strong id=&quot;second&quot;&quot;>Here it is</strong>. </div>

  3. XML (debug) snippet:

    <page-content mode="formatted"><p>&lt;div id=&amp;quot;first&amp;quot;&gt; &lt;strong id=&amp;quot;second&amp;quot;&amp;quot;&gt;Here it is&lt;/strong&gt;. &lt;/div&gt;</p>

  4. Call to display the content:

a. from my master template

`<xsl:apply-templates  select="*//entry[@id=$thisEntry]/page-content" />`

b. to my (imported) "get-static.xsl"

 `<xsl:template match="page-content">
   ...
          <xsl:copy-of select="../page-content/*"/>`

Any pointers would be tremendously appreciated.

Argh, sorry. I just realized there's an HTML syntax error in my code (double-double quotes in 'id="second""').

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details