MDN

Go Back   Mambo - Forums Closed for posting > Mambo 3rd Party Addons > Modules

Reply
 
Thread Tools Search this Thread Display Modes
Old April 9th, 2005, 19:59   #1
konlong
 
konlong's Avatar
 
Join Date: Oct 2003
Location: Delaware
Posts: 457
konlong is on a distinguished road
Default PHP code in a Module: A wrapper mod

My newest Module allows for processing PHP scripts, which are passed through the parameter interface. It is based on the kl_php mambot. The module was written in response to a thread in the Custom Development forum.
( http://forum.mamboserver.com/showthread.php?t=38919 )

Changes October 7th, 2005:
added feature to view raw html output
Wrap the output with a span, table or nothing
You may now specify the class for the span or the
'module class suffix' for the table wrap.
Attached Files
File Type: zip mod_kl_evalphp.zip (1.9 KB, 1956 views)

Last edited by konlong : October 7th, 2005 at 20:49. Reason: see feature list 10/7/2005
konlong is offline   Reply With Quote
Old April 9th, 2005, 23:42   #2
gsbe
 
gsbe's Avatar
 
Join Date: May 2004
Location: Lexington, VA
Posts: 992
gsbe is on a distinguished road
Thumbs up process PHP scripts in module parameters

Nice work, konlong. I'll definitely be investigating the possibilities of this addon. Can you give some suggestions?
gsbe is offline   Reply With Quote
Old April 10th, 2005, 04:53   #3
konlong
 
konlong's Avatar
 
Join Date: Oct 2003
Location: Delaware
Posts: 457
konlong is on a distinguished road
Default

Quote:
Originally Posted by gsbe
Nice work, konlong. I'll definitely be investigating the possibilities of this addon. Can you give some suggestions?
You may think of this addon as a Wrapper module, or the lazy mans approach to module creation :-p

The thorniest issue I had with this mod was the handling of the text string returned from the textarea. It turns out that newlines are suffixed with <br />

So if you meet with problems I may offer an alternative which uses a text box.

John L
konlong is offline   Reply With Quote
Old April 15th, 2005, 20:20   #4
wolfyman
 
Join Date: Apr 2005
Posts: 81
wolfyman is on a distinguished road
Default

I want to use this for including a php on my site... how do you use it?!

On my main page right now I use this code in the index file:
PHP Code:
<?php
$number 
"1";
include(
"cutenews/show_news.php");
?>
I'm doing a test install right now for mambo, so I am assuming the correct path to use right now is
PHP Code:
<?php
$number 
"1";
include(
"../cutenews/show_news.php");
?>
as my mambo directory is /mambo.

I'm new at this, so the more details the better! Thanks in advance.

edit... actually I guess I don't even know how to use a module correctly :P
wolfyman is offline   Reply With Quote
Old April 15th, 2005, 21:41   #5
konlong
 
konlong's Avatar
 
Join Date: Oct 2003
Location: Delaware
Posts: 457
konlong is on a distinguished road
Default

Modules are generally those bits that display information in the left or right columns. If what you want is to parse a php script in your content (i.e. the main body of your page) then you would do better with a mambot such as kl_php.. Look in the Mambots development forum for kl_php.

John L
konlong is offline   Reply With Quote
Old April 15th, 2005, 21:53   #6
wolfyman
 
Join Date: Apr 2005
Posts: 81
wolfyman is on a distinguished road
Default

I am so confused here... to install a mambot, you go to mambots>install, correct? then choose your file, upload, done, right? I'm getting "xml is not for a mambot" error.
wolfyman is offline   Reply With Quote
Old April 15th, 2005, 22:12   #7
konlong
 
konlong's Avatar
 
Join Date: Oct 2003
Location: Delaware
Posts: 457
konlong is on a distinguished road
Default

you are probably using the wrong zip mod_evalphp.zip is the module version, while kl_php.zip is the mambot.
konlong is offline   Reply With Quote
Old April 15th, 2005, 22:39   #8
wolfyman
 
Join Date: Apr 2005
Posts: 81
wolfyman is on a distinguished road
Default

doh! ok, that worked, now I have the module and the mambot installed. How do I use the things? I'm trying to include the php in the main page, and I also want to add phpadsnew to my banners area. I'm assuming these both work the same way.

I just don't get how to create the things... For example, when I try to add the invocation code for phpadsnew I go to components>banners>...no love, I can only add banners. Then I try modules> site modules> create new... I get the optioin to create a module, but it won't let me enter my invocation code (that I can see). Thanks for your help konlong
wolfyman is offline   Reply With Quote
Old April 16th, 2005, 11:20   #9
wolfyman
 
Join Date: Apr 2005
Posts: 81
wolfyman is on a distinguished road
Default

Ok, I figured the last part out, I had to enable the "NO WYSIWYG" mambot.

I don't understand how to use the kl_php command/mambot.... I have it enabled, published, and when I try to include anything php it does not work. I can see it in the source codde, so I guess it's not processing it....

I tried using

Code:
{kl_php}
<?php
$number = "1";
include("../cutenews/show_news.php");
?> 
{/kl_php}
but no love... help?
wolfyman is offline   Reply With Quote
Old April 16th, 2005, 14:45   #10
konlong
 
konlong's Avatar
 
Join Date: Oct 2003
Location: Delaware
Posts: 457
konlong is on a distinguished road
Default

The module is expecting php script so leave out the <?php ?> tags

Also are you sure your file is located outside your root?

John L

Last edited by konlong : August 19th, 2005 at 18:25. Reason: corrected spelling error
konlong is offline   Reply With Quote
Old April 16th, 2005, 14:53   #11
wolfyman
 
Join Date: Apr 2005
Posts: 81
wolfyman is on a distinguished road
Default

actually I made a little progress...

I am now using
Code:
{kl_php}
$number = "1";
include("../cutenews/show_news.php");
return $number;    
{/kl_php}
And it's working somewhat. I get an eror - if you don't mind, you can take a look.

(NSFW) http://www.beerandshots.com/mambo (NSFW, I have a few adult ads on the page)

This works with no errors on the main page http://www.beerandshots.com

Code:
<?php
$number = "1";
include("../cutenews/show_news.php");
?>
I also have one other problem on that page so far.... in the right column, it's easy to spot.

Thanks John!
wolfyman is offline   Reply With Quote
Old April 16th, 2005, 15:39   #12
konlong
 
konlong's Avatar
 
Join Date: Oct 2003
Location: Delaware
Posts: 457
konlong is on a distinguished road
Default

It looks as if you are having problems with relative paths. Is it possible to change them to absolutes?

Re: The right column --- You need to use mod_kl_evalphp as this is a module.

John

Last edited by konlong : April 16th, 2005 at 20:21. Reason: corrected module name
konlong is offline   Reply With Quote
Old April 16th, 2005, 17:57   #13
wolfyman
 
Join Date: Apr 2005
Posts: 81
wolfyman is on a distinguished road
Default

Quote:
Originally Posted by konlong
It looks as if you are having problems with relative paths. Is it possible to change them to absolutes?

Re: The right column --- You need to use mod_evalphp as this is a module.

John
do you mean "mod_kl_evalphp"? I can't find a mod_evalphp anywhere, and I can't seem to get the other things to work...
wolfyman is offline   Reply With Quote
Old April 16th, 2005, 20:20   #14
konlong
 
konlong's Avatar
 
Join Date: Oct 2003
Location: Delaware
Posts: 457
konlong is on a distinguished road
Default

Yes, I forgot my sig 'kl_'

should be mod_kl_evalphp
konlong is offline   Reply With Quote
Old April 16th, 2005, 23:15   #15
wolfyman
 
Join Date: Apr 2005
Posts: 81
wolfyman is on a distinguished road
Default

I tried it both ways...
Code:
{mod_kl_evalphp}
include('../top20.php');
{/mod_kl_evalphp}
didn't work either.

The only real idea I have at the moment is when I click modules>all modules>kl evalPHP (that's the way it comes up in my list, or something similar) I don't get the option to edit the content. When I look at the mod_kl_evalphp.xml in my ftp though, I see where it says "Hello World", as if I should be able to ad code somewhere... and when I ad the module to my site through the site module control, it shows "hello world" on the page! I just can't figure out where to edit it or place my php code.

hopefuly you can decipher what I wrote, the code and exact paths are from memory through a fair amount of alcohol consumption tonight :P Konlong, I appreciate the help!

Wolfy
wolfyman is offline   Reply With Quote
Old April 17th, 2005, 05:25   #16
konlong
 
konlong's Avatar
 
Join Date: Oct 2003
Location: Delaware
Posts: 457
konlong is on a distinguished road
Default

You are treating mod_kl_evalphp as if it is a mambot, which it is not. mod_kl_evalphp is a Module! Go to the module manager and place include('../top20.php'); in the PHP script parameter, then publish the module.

Note: as it is a module you may clone it and run different scripts.

John L
konlong is offline   Reply With Quote
Old April 18th, 2005, 17:10   #17
mom2nine
 
Join Date: Jun 2004
Posts: 20
mom2nine is on a distinguished road
Default Grateful for help

I would really like a quick demonstration for using this mod. it installed just fine (so did the mambot) but all i get are error messages. I tried
{kl_php}
$number = "1";
include("oldhouse.php");
return $number;
{/kl_php}

and that didn't work.
mom2nine is offline   Reply With Quote
Old April 18th, 2005, 17:34   #18
konlong
 
konlong's Avatar
 
Join Date: Oct 2003
Location: Delaware
Posts: 457
konlong is on a distinguished road
Default

See my previous response. Your quetion is not clear, are you asking about the Module 'mod_kl_evalphp' or the Mambot '{kl_php}'?

John L
konlong is offline   Reply With Quote
Old April 18th, 2005, 18:38   #19
mom2nine
 
Join Date: Jun 2004
Posts: 20
mom2nine is on a distinguished road
Default Both!

I've installed the module AND the mambot. What I need to know is how to structure the code in the module so it will display the page I'm including.
mom2nine is offline   Reply With Quote
Old April 18th, 2005, 19:53   #20
konlong
 
konlong's Avatar
 
Join Date: Oct 2003
Location: Delaware
Posts: 457
konlong is on a distinguished road
Default

In that case all you have to do is open the module using the module manager and locate the parameters. Then (using your example) place the following in the textarea box labeled PHP script.
Code:
$number = "1";
include("oldhouse.php");
return $number;
John L
konlong is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with admin section sarmiento General Questions 16 July 19th, 2006 23:21
Problem with php script in module mrgee General Questions 0 November 26th, 2004 15:44
Highlight PHP Code Gianni_T General Questions 0 November 9th, 2004 03:03
Module within a Module - editor removes php tags, why? jhdesign General Questions 2 November 7th, 2004 03:34
Php data in a module lilomadio General Questions 0 August 5th, 2004 10:07


All times are GMT -7. The time now is 09:19.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.