Page 1 of 1

Plugins give me a headache :(

Posted: Sun Dec 14, 2008 5:43 pm
by unnamed7
Hi, can someone tell me what could be wrong with my plugins ?

for example, i'am making plugin (udt):

Code: Select all

function my_name() {
  echo 'test';
}
and i get error like

Code: Select all

Fatal error: Cannot redeclare my_name()  (previously declared in /home/users/test/public_html/inetic/lib/content.functions.php(856) : eval()'d code:8) in /home/users/test/public_html/inetic/lib/content.functions.php(856) : eval()'d code on line 4
it always worked for me but now suddenly i cant make normaln udt :/
can it be becouse of multilingual modification ?

one funny thing, when i get preview of page in admin area it works fine :)

please help and thanks

Re: Plugins give me a headache :(

Posted: Mon Dec 15, 2008 12:20 am
by duclet
I think this comes from the fact that the template is parsed twice (the first time so all variables are set, and the second time it is used). If you fix this problem by adding an if statement around the function. Just add a function_exists to see whether or not the function already exists, if not, then you can declare the function. Though, why are you declaring a function inside of a UDT?

Re: Plugins give me a headache :(

Posted: Mon Dec 15, 2008 1:20 am
by calguy1000
wrong.

the user has yet to illustrate how and when the UDT is called.

And declaring a function inside of a UDT is perfectly valid if you are aware of how thing work, and/or test things until you learn how they work.

Re: Plugins give me a headache :(

Posted: Mon Dec 15, 2008 7:55 am
by unnamed7
udt is called on normal page (content) - {my-udt}

its a bit wierd for me that in preview i can see that my plugin is working, but in frontend not
always something like using a function was working for me

any advices ?