phpjoomlajoomla1.5joomla-article

Why is my PHP in articles being interpreted literally as a string instead of as 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.

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.


Solution

  • 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.