Mobile app version of vmapp.org
Login or Join
Samaraweera270

: Dynamic content in Joomla - Embedding PHP in Joomla articles Preface: I recently inherited a website project that my employer had summer interns create. Being non-technical types, they opted for

@Samaraweera270

Posted in: #Joomla #Php

Preface:

I recently inherited a website project that my employer had summer interns create. Being non-technical types, they opted for Joomla CMS to create the content. They also opted to make all of the current content static, and to manage updates manually, article by article (these were high school interns with little/no technical background).

As part of my takeover, one of my first goals is to get all of the volatile data (company information, event information, etc) into MySQL, and then load the content into the articles dynamically. Joomla already has a MySQL database; I've added a table to it, storing the frontend content I want to load dynamically, and now I want to make one of my articles pull from that table, row by row, and spit out some HTML to format it. To my knowledge, the easiest way to do this is to use PHP to embed SQL queries (if I'm wrong about that, feel free to suggest alternate dynamic content models in Joomla!), and so the logical first step is to get some PHP embedded in an article.

Problem:

I have tried using the Sourcerer and DirectPHP extensions, but in both cases (and with manually inserted PHP code), I find that the PHP is getting ignored. For example, I made an article with nothing but this:

<?php
echo "This is a PHP string";
?>


And when I load the article, it is empty. I've scanned the settings and configuration pages of the Joomla install and done a number of Google searches, and thus far haven't been able to find anything. I bet I'm missing something pretty simple, but I don't know what. Any suggestions?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Samaraweera270

2 Comments

Sorted by latest first Latest Oldest Best

 

@Sent6035632

If you write your code in "Source Mode" directphp not work. write your code in the WYSIWYG window

10% popularity Vote Up Vote Down


 

@Angela700

You can try Jumi extension. I used it in modules, but should work also inside content.

As an alternative, you can create your custom module (standard HTML or coded with Jumi) and easily include it inside an article with this sintax:

{loadposition position_name}


Here more info: How to include modules in Content item (for Joomla 1.5.x)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme