Plugins give me a headache :(

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
unnamed7
Forum Members
Forum Members
Posts: 42
Joined: Tue Dec 05, 2006 1:53 pm

Plugins give me a headache :(

Post 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
User avatar
duclet
Forum Members
Forum Members
Posts: 187
Joined: Fri Jun 23, 2006 12:55 pm

Re: Plugins give me a headache :(

Post 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?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Plugins give me a headache :(

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
unnamed7
Forum Members
Forum Members
Posts: 42
Joined: Tue Dec 05, 2006 1:53 pm

Re: Plugins give me a headache :(

Post 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 ?
Post Reply

Return to “Developers Discussion”