doutuan6158 2011-04-23 13:59
浏览 65
已采纳

Joomla:在文章中写出真正的PHP

I am trying to find a way to write pure PHP in my articles with Joomla (currently using 1.5). The closest I got so far was to use a plugin called Sourcerer (see link)

The issue is that the PHP code is actually being rendered as HTML. When I write the below code via the Sourcerer editor:

<?php echo "Hello world"; ?> 

This is what is being written to the article:

<span>&lt;</span>?php echo "Hello world"; ?<span>&gt;</span>

I am afraid that at some point this is going to break my PHP if I come up with more complex code. Also this makes the code hardly readable. Finally the issue with Sourcerer is that you can only insert new code, you can't edit what you previously added.

[Q] Does anybody know a way to write pure PHP into articles?

I would like to insist on the fact that it has to be within articles. I already found a way to do it in modules or components, for instance with Jumi (see link)

  • 写回答

4条回答 默认 最新

  • dongliechuich10319 2011-04-24 01:38
    关注

    I have used Sourcerer a couple of times and it does allow one to insert PHP snippets into articles without issues. If your php is being rendered as html, it sounds like the php isn't getting parsed as php - first thing is to make sure that the sourcerer plugin is indeed enabled so it can allow your php scripts to get parsed. (check plugin enabled status here: extensions->plugin manager->sourcerer).

    Also, use the sourcerer ("Insert Code") button at the bottom of your WYSIWYG editor when adding your PHP scripts - it keeps the formatting/syntax highlighting and ensures that it is escaped properly with the {source} {/source} tags.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?