Hi there,
I am creating a CMS with dynamic module(s) to be included in content using custom templates. The user selects them by double clicking a list item and the text is applied to the text area as <[module_mymodule]> (mymodule could be a number of module templates in a directory.
The code works ok but only outputs the results as actual text and is not the include statement which I want to fire. If I put the word include out of the brackets the statement does triggers correctly but includes all the templates because it is in the loop that gathers the info.
Basically looks for text in the content <[module_mymodule]> and should replace it with include ('modules/module_mymodule.php');
Here is the code. What I need to know is how to output the str_replace to find and utilise the require statment correctly.
Any help greatly appreciated.
$content = $row_GetContent['main_text'];
if ($handle = opendir('modules/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "_notes") {
$my_file = str_replace(".php", "" , $file);
$module = "<[" . $my_file . "]>";
$content = str_replace($module, "include('modules/" . $my_file . ".php')" , $content);
} // End If
} // End While
closedir($handle);
} // End If
echo $content;