How to put an existing php function into module

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

How to put an existing php function into module

Post by pvh123 » Thu Aug 23, 2007 9:12 pm

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.
;) pieter

User avatar
AmyStephen
Joomla! Guru
Joomla! Guru
Posts: 579
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: How to put an existing php function into module

Post by AmyStephen » Thu Aug 23, 2007 9:46 pm

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 :)
~*~ Joomla!'s Queen of the Blues - Jennifer Marriott ~*~
http://OpenSourceCommunity.org/node/1719/

User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: How to put an existing php function into module

Post by pvh123 » Fri Aug 24, 2007 4:27 am

Thanks Amy, that is what I was looking for and could not find back.
You are a star :)

Rgrds,
Pieter
;) pieter

User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

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

Post by pvh123 » Fri Aug 24, 2007 9:13 am

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.
Last edited by pvh123 on Fri Aug 24, 2007 9:16 am, edited 1 time in total.
;) pieter

User avatar
AmyStephen
Joomla! Guru
Joomla! Guru
Posts: 579
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: How to put an existing php function into module

Post by AmyStephen » Fri Aug 24, 2007 3:06 pm

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 :)
~*~ Joomla!'s Queen of the Blues - Jennifer Marriott ~*~
http://OpenSourceCommunity.org/node/1719/

erdsiger
Joomla! Intern
Joomla! Intern
Posts: 72
Joined: Sat Nov 11, 2006 9:34 pm
Location: Hungary

Re: How to put an existing php function into module

Post by erdsiger » Fri Aug 24, 2007 3:22 pm

Moderator note: Topic moved from 1.5 General Questions to Joombie Coding Q/A.
Gergo Erdosi

User avatar
seadap
Joomla! Intern
Joomla! Intern
Posts: 95
Joined: Mon Dec 04, 2006 12:22 am
Contact:

Re: How to put an existing php function into module

Post by seadap » Fri Aug 24, 2007 3:54 pm

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!
Knowledge is realizing that the street is one-way, wisdom is looking both directions anyway.

joatmon
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Thu Nov 10, 2005 8:54 pm

Re: How to put an existing php function into module

Post by joatmon » Fri Aug 24, 2007 6:34 pm

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

User avatar
seadap
Joomla! Intern
Joomla! Intern
Posts: 95
Joined: Mon Dec 04, 2006 12:22 am
Contact:

Re: How to put an existing php function into module

Post by seadap » Fri Aug 24, 2007 10:29 pm

That's a great idea joatmon.  Thanks for that.  Is there already a module like that in 1.5?  Anybody know?
Knowledge is realizing that the street is one-way, wisdom is looking both directions anyway.

User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: How to put an existing php function into module

Post by pvh123 » Sat Aug 25, 2007 6:42 am

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.
 
;) pieter

User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: How to put an existing php function into module

Post by pvh123 » Sat Aug 25, 2007 6:45 am

-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.
;) pieter

User avatar
tjay
Joomla! Intern
Joomla! Intern
Posts: 73
Joined: Thu Aug 18, 2005 1:50 am
Location: New Orleans
Contact:

Re: How to put an existing php function into module

Post by tjay » Sat Aug 25, 2007 12:52 pm

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.
This day it is my wish that I helped you to live

User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: How to put an existing php function into module

Post by pvh123 » Sat Aug 25, 2007 3:48 pm

Thanks, tjay I have downed it and wil have a look at it. Let you know how it worked out.
;) pieter

User avatar
tjay
Joomla! Intern
Joomla! Intern
Posts: 73
Joined: Thu Aug 18, 2005 1:50 am
Location: New Orleans
Contact:

Re: How to put an existing php function into module

Post by tjay » Sat Aug 25, 2007 5:25 pm

Please do, I have been wondering if it would make a good skeleton type thing for more developed modules
This day it is my wish that I helped you to live

User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: How to put an existing php function into module

Post by pvh123 » Sat Sep 01, 2007 8:21 pm

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.
;) pieter

joatmon
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Thu Nov 10, 2005 8:54 pm

Re: How to put an existing php function into module

Post by joatmon » Wed Oct 03, 2007 8:37 pm

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
Attachments
mod_tcwphp.zip
(2.77 KiB) Downloaded 37 times

User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: How to put an existing php function into module

Post by pvh123 » Wed Oct 03, 2007 9:14 pm

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.
;) pieter

User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: How to put an existing php function into module

Post by pvh123 » Tue Oct 16, 2007 1:47 pm

@joatmon I did install your module, but it gave a blank screen when loading the homepage.
;) pieter


Post Reply