Page 1 of 1

Include in plugin

Posted: Wed May 24, 2006 12:03 am
by brady
I am tryong to write a simple plugin.However I am running into problems.I need to include files with include() but whenever I do this nothing happens.  My template from the point of the tag on does not display nor anything in the included file.But I don't get an error message.  Can anyone tell me what is going on?
I know that is a little confusing so here is an example

My plugin

Code: Select all

<?php
function smarty_cms_function_test($params, &$smarty) {
include("test.php");
}

function smarty_cms_help_function_test() {
	?>
	<h3>What does this do?</h3>
	<p>Include a file</p>
	<h3>How do I use it?</h3>
	<p>This is just a basic tag plugin.  You would insert it into your template or page like so: <code>{test}</code>
	<h3>What parameters does it take?</h3>
	<?php
}

function smarty_cms_about_function_test() {
	?>
	<p>Author: Brady</p>
	<p>Version: 1.0</p>
	
	<?php
}

?>
test.php

Code: Select all

<?php
echo "I can't see this";
?>

Re: Include in plugin

Posted: Wed May 24, 2006 12:12 am
by calguy1000
It all depends on what your current working directory is, as to wether you can include a relative filename, try putting an absolute path in there.  then it should find it.

Re: Include in plugin

Posted: Wed May 24, 2006 12:53 am
by Elijah Lofgren
This may help:

Code: Select all

include (dirname(__FILE__).'/test.php');