Page 1 of 1

How to put an existing php function into module

Posted: Thu Aug 23, 2007 9:12 pm
by pvh123
I have been using an application for users to play music on my website. This was (and still is) on the ASP driven website
This app is also available as a php script and the total package consists of the scriptfile, a preferencesfile, read in by the script and the mp3 files played by the script.
Long time ago, at least in the early days of J! 1.5 , I read a post explaining how to put your own app into a Joomla 1.5 module. Nothing to fancy, just make it into a module so I can run it from a menu or module position.

I made some changes to the scriptfile and setup an xml file so I could do the install.
Next step would be how to get the output of the script into the webpage and there I am stuck. Thats why I was thinking about this old post which I cannot find anymore.

It is too small a app to go MVC etc.

Re: How to put an existing php function into module

Posted: Thu Aug 23, 2007 9:46 pm
by AmyStephen
Pieter -

Would the v 1.5 Module Tutorial be of assistance? Might be a good app to try your hand at an extension.

Good luck!
Amy :)

Re: How to put an existing php function into module

Posted: Fri Aug 24, 2007 4:27 am
by pvh123
Thanks Amy, that is what I was looking for and could not find back.
You are a star :)

Rgrds,
Pieter

Re: How to put an existing php function into a module

Posted: Fri Aug 24, 2007 9:13 am
by pvh123
I had a look at this tutorial and found that it is rather tricky for me to use that example for the script I have.
In my script is no db access but flat files (no helper needed I think) and the output is echo'ed all over the place.
So, I do not know where to start.
I cannot publish the scriptfile in the forum because it has been payed for.

Re: How to put an existing php function into module

Posted: Fri Aug 24, 2007 3:06 pm
by AmyStephen
Pieter -

You might consider joining a growing group of us in the Joomla! 101 Coding forum. The Joomla! Coding Q/A thread is a good place to ask this question. In fact, I'll ask that this thread be moved into that forum - I hope that's okay with you!

It's a cool group. Lots of new curriculum being developed. Instructions for downloading and configuring an IDE that hooks into JoomlaCode's SVN environment, and perhaps most importantly, lots of very smart people who can answer these questions for you and ME as we learn how to do this.

I think you'd enjoy it; these are geeks and Joomla! fans, just like us!
Amy :)

Re: How to put an existing php function into module

Posted: Fri Aug 24, 2007 3:22 pm
by erdsiger
Moderator note: Topic moved from 1.5 General Questions to Joombie Coding Q/A.

Re: How to put an existing php function into module

Posted: Fri Aug 24, 2007 3:54 pm
by seadap
Welcome to J!101 Pieter.  I don't have the answer to your question but I'm sure you've come to the right place.  Ready guys?  GO!

Re: How to put an existing php function into module

Posted: Fri Aug 24, 2007 6:34 pm
by joatmon
Hi Pieter,

I'm not sure if this will help you out at all or not, but if I were doing what you're trying to do, I might be inclined to build a wrapper module that would take a parameter containing a path to the actual PHP file to include and possibly a method to execute.  This appears to be especially true in your case since it sounds like the script you have doesn't really do any separation of code and presentation.

The actual module would be pretty small and not too complex to build.  Basically you could take the hello world example that Amy posted and modify the helper to read the module parameters and 'include' or 'require' the PHP script identified by the parameter.

Does that make sense?

--joatmon

Re: How to put an existing php function into module

Posted: Fri Aug 24, 2007 10:29 pm
by seadap
That's a great idea joatmon.  Thanks for that.  Is there already a module like that in 1.5?  Anybody know?

Re: How to put an existing php function into module

Posted: Sat Aug 25, 2007 6:42 am
by pvh123
AmyStephen wrote:
I think you'd enjoy it; these are geeks and Joomla! fans, just like us!
Amy :)


Ok, Amy Let me join the geeks at my age :).
You are quite right. May be next time I can help someone else and learn while doing it.
 

Re: How to put an existing php function into module

Posted: Sat Aug 25, 2007 6:45 am
by pvh123
-joatmon,

Ihave beenlooking at the Hello World example but was thinking a differenmt way.
The way you propose is simple and I will try that and see what happens.

Re: How to put an existing php function into module

Posted: Sat Aug 25, 2007 12:52 pm
by tjay
try this

http://extensions.joomla.org/component/ ... Itemid,35/

Enables insertion of any code into a custom module in Joomla! 1.5 - PHP, HTML, Javascript, CSS.

Re: How to put an existing php function into module

Posted: Sat Aug 25, 2007 3:48 pm
by pvh123
Thanks, tjay I have downed it and wil have a look at it. Let you know how it worked out.

Re: How to put an existing php function into module

Posted: Sat Aug 25, 2007 5:25 pm
by tjay
Please do, I have been wondering if it would make a good skeleton type thing for more developed modules

Re: How to put an existing php function into module

Posted: Sat Sep 01, 2007 8:21 pm
by pvh123
A little disappointing outcome of this particular function that I wanted to "Joomalise".
I have spoken with the owner, as you know it is a commercial product, and was told that the script cannot be hacked in order to embed joomla code. Because if it is edited, it is corrupt.

I still have one outstanding question with him and that is whether he is willing to put 2 lines of code in, the YOURBASEPATH thing, and than generate a new script for me. Just wait and see. The path code is needed because the script is heavenly driven by parameters from a textfile.

Just to let you know.

Re: How to put an existing php function into module

Posted: Wed Oct 03, 2007 8:37 pm
by joatmon
Hi Pieter,

I'm not sure if you ever got your question answered from the developer of your component, but if you're still interested, I have a module that allows you to include a php script.  It's slightly different than the one you were earlier given because that one allowed you to paste code into a text box.  This one allows you to put a path to the script you want run with an optional method to execute.

I would have posted it earlier, but I've been having Subversion issues and had to finally just set up my own svn server.  Anyway, I digress...

I've attached the module for your pleasure.

--joatmon

Re: How to put an existing php function into module

Posted: Wed Oct 03, 2007 9:14 pm
by pvh123
No, I never got a response from the owner. He did not want to make the changes I asked him to do. So, I have digressed from this product.
But, I am very glad to take up your offer and give it a try.

Thanks again, joatmon.

Re: How to put an existing php function into module

Posted: Tue Oct 16, 2007 1:47 pm
by pvh123
@joatmon I did install your module, but it gave a blank screen when loading the homepage.