Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
gizmo99
New Member
New Member



Joined: Jan 03, 2007
Posts: 2

PostPosted: Tue Jan 02, 2007 11:48 pm Reply with quote

Hey. Totally new at this webmaster stuff. Got basic knowledge in alot of programming languages -- nothing spectacular -- but totally new to PHP and Nuke.

Was wondering if there was a better, more in-depth tutorial on module creation besides the one found in the Nuke HOWTO. One that would take into consideration the reader not knowing PHP would be great, but I'll read anything; I'm bound to figure it out eventually given enough sources of information.
 
View user's profile Send private message
hitwalker
Sells PC To Pay For Divorce



Joined:
Posts: 5661

PostPosted: Wed Jan 03, 2007 3:06 am Reply with quote

nope...thats it..
but there's not more to it realy....
or buy the php nuke book....
 
View user's profile Send private message
jakec
Site Admin



Joined: Feb 06, 2006
Posts: 3048
Location: United Kingdom

PostPosted: Wed Jan 03, 2007 7:01 am Reply with quote

What exactly are you trying to do?

Display some basic HTML, or something which pulls out data from the DB?

If it's the later you will need to know something about PHP and there's a few good books out there.
Guardian is currently putting together a series of tutorials on PHP and security. See here: [ Only registered users can see links on this board! Get registered or login! ]

I must admit I'm relatively new to all this and recently on Guardians site I posted a discussion about creating a basic module, which may help.
See here: [ Only registered users can see links on this board! Get registered or login! ]
 
View user's profile Send private message
hitwalker







PostPosted: Wed Jan 03, 2007 8:00 am Reply with quote

nice links posted jakec,but thats just php and doesnt explain how a module is created ....

simple said.....
first part of the module is this :

Code:


<?php
if ( !defined('MODULE_FILE') )
{
die("You can't access this file directly...");
}

require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);

include("header.php");


Then we reach the part where we wanna show any junk we have in mind...

that starts by :

OpenTable();
echo "here comes the content...";




then after that we close it again....

CloseTable();
include("footer.php");
 
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Wed Jan 03, 2007 9:08 am Reply with quote

The How-To is really pretty good at explaining the basics of module creation.

There is also the book "Building Websites with PHP-Nuke" that walks through a lot of this stuff.

_________________
GCalendar - An Event Calendar for PHP-Nuke
Member_Map - A Google Maps Nuke Module 
View user's profile Send private message
hitwalker







PostPosted: Wed Jan 03, 2007 9:44 am Reply with quote

@gremmie

let me quote myself......

Quote:
or buy the php nuke book
 
Gremmie







PostPosted: Wed Jan 03, 2007 10:41 am Reply with quote

Well since you failed to mention the title, I thought I would reply with that information. Please excuse me for trying to be helpful.
 
hitwalker







PostPosted: Wed Jan 03, 2007 1:41 pm Reply with quote

no problem... Laughing
but php nuke book also goes to packtpub via google....but still .....chances that somebody will actualy buy the book for the howto modules story is like null.
 
jakec







PostPosted: Wed Jan 03, 2007 1:58 pm Reply with quote

hitwalker wrote:
nice links posted jakec,but thats just php and doesnt explain how a module is created ....


Although I perhaps didn't explain how a module is created I thought the link to the discussion on the Code Authors site would be helpful, as it gives an example of a very basic module. Wink
 
Gremmie







PostPosted: Wed Jan 03, 2007 2:58 pm Reply with quote

hitwalker wrote:

but php nuke book also goes to packtpub via google....


I still don't understand the reason for your post. I provided a specific title whereas you provided a vague google search term. So why are you on my case for being more specific?

hitwalker wrote:

but still .....chances that somebody will actualy buy the book for the howto modules story is like null.


I bought it for that reason, that and the tutorial on making themes.
 
hitwalker







PostPosted: Wed Jan 03, 2007 3:16 pm Reply with quote

im not on your case,...i dont know what gives you that idea..
personaly i feel this topic was answered good enough...
whatever term was posted,that doesnt matter....it was clear enough.
 
Donovan
Client



Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Wed Jan 03, 2007 3:19 pm Reply with quote

You can read all you want to and you will pick up the basic idea. Me on the other hand, had to roll up my sleaves and deconstruct a module and see how it works before I understood. Get yourselve a development server and dive in.

Only way I learn is by example, and trial and error. For example I am finding it much eaiser to get data written to the database by using functions than by _POST in a form.
 
View user's profile Send private message Visit poster's website ICQ Number
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Wed Jan 03, 2007 6:20 pm Reply with quote

I agree with Donovan. You only learn by doing...

Take a sample module that does something close to what you're after and hack it up. We call it at work "stealing shamelessly".

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
fkelly
Former Moderator in Good Standing



Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY

PostPosted: Thu Jan 04, 2007 8:45 am Reply with quote

Just be aware that there are modules and there are modules. The admin program recognizes modules based on the files that are in the /modules directory. So if you have a directory called xxx and an index.php file in there admin will think you have a module. It will create an entry in the modules table for that module and you will be able to go to modules administration in the admin panel and customize settings for it (active, inactive, groups that can see it, etc). The simple module example that was given earlier in the thread would work ... you can have it do nothing but echo "hello world" and it's still a module.

But as I said, then there are modules. If you look at the admin directory of a typical nuke module you will see that there are case and links files. The admin panel looks at them, if they exist to determine whether you have set up administration functions for the module and if so what to do. To really understand this you need to work thru admin.php and trace what happens. It's not for the faint of heart nor is it documented that I know of (but I haven't looked at the book that's posted, that's on my list).

In my view one of the biggest p.i.t.a.'s with dealing with nuke modules is understanding how the action attribute of a submit on a form works. You need to look at several modules to get that straight, the form has to communicate with whatever "action" takes place when a submit is done thru modules.php. In standard PHP programming you'd just go direct to the action program or function but in Nuke you need to go thru modules. It's fine once you get it but understanding it and doing it well is something else. Also, whenever you go from one screen to another in Nuke you are likely, like it or not, to be going thru mainfile and header and sentinel and a bunch of other stuff. All those programs are there to help you but if you do something they don't like they are likely to step on your toes. And tracing the execution path can be another p.i.t.a.

Hope that helps and it's definitely not meant to be discouraging. You can start by creating a module that doesn't have an administrative component and then move up as you gain experience.
 
View user's profile Send private message Visit poster's website
gizmo99







PostPosted: Fri Jan 05, 2007 11:16 am Reply with quote

Wow, I post something and forget about it for two days and it's full of information. Shocked Thanks guys!

How does Opentable(); and closetable(); work? Where are they defined at? Apparently, besides those two and the line you have to include at the beginning, the rest of the code is regular PHP and HTML. I had figured that there was alot more to it, but it looks like I'll need to find a PHP tutorial instead!
 
montego







PostPosted: Fri Jan 05, 2007 11:24 am Reply with quote

The functions are required to be a part of every theme.php script (or somehow included in a file from there).

Besides those, the only real "infrastructure" that you should re-use is the database calls. Look at how one of the modules is doing this -- through the db abstraction layer class -- and then you are ready to "rock and roll".

Have fun! It is a journey they will not leave you the same... Wink
 
pinkbeef
Client



Joined: Jul 19, 2005
Posts: 68

PostPosted: Mon Feb 05, 2007 12:04 pm Reply with quote

Hi,
Im more a zen cart person but nukephp does have it advantages.
so i got an empty module that i borrowed from another and have removed the copyright only to shortan the post. i could do with a bit of advice here from the usual team. forget about the sql calls and the switch in the case file I know the problems there.

the public index page code is;

?php

if ( !defined('MODULE_FILE') )
{
die("You can't access this file directly...");
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
$pagetitle = "- "._EMPTY."";
global $prefix, $db, $sitename, $admin, $multilingual, $module_name, $admin_file;
include("header.php");
title("$sitename: "._EMPTY."");

echo "public section";

include("footer.php");

?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

the admin index page code is;

?php

if ( !defined('ADMIN_FILE') )
{
die ("Access Denied");
}
global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT title, admins FROM ".$prefix."_modules WHERE title='Encyclopedia'"));
$row2 = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM ".$prefix."_authors WHERE aid='$aid'"));
$admins = explode(",", $row['admins']);
$auth_user = 0;
for ($i=0; $i < sizeof($admins); $i++) {
if ($row2['name'] == "$admins[$i]" AND !empty($row['admins'])) {
$auth_user = 1;
}
}

if ($row2['radminsuper'] == 1 || $auth_user == 1) {

/*********************************************************/
/* Sections Manager Functions */
/*********************************************************/

global $admin, $bgcolor2, $prefix, $db, $currentlang, $multilingual, $admin_file;

include("header.php");

echo "admin section";

include("footer.php");

}

else {
include("header.php");
GraphicAdmin();

include("footer.php");
}

?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

the case code is;

?php


if ( !defined('ADMIN_FILE') )
{
die ("Access Denied");
}
$module_name = "Empty";
include_once("modules/$module_name/admin/language/lang-".$currentlang.".php");

switch($op) {

case "empty":
include("modules/$module_name/admin/index.php");
break;

}

?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

the links code is;

?php


if ( !defined('ADMIN_FILE') )
{
die ("Access Denied");
}
global $admin_file;
adminmenu("".$admin_file.".php?op=empty", ""._EMPTY."", "empty.gif");

?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

i have omitted the lang- files,
the big question is will i be opening a hole in my site if i creat a module using the above code as a template. and if so what would be the cure.
 
View user's profile Send private message
montego







PostPosted: Tue Feb 06, 2007 5:56 pm Reply with quote

pinkbeef, this is just slightly over the border of

OffTopic

In my opinion... this thread was a question around "is there a tutorial on how to create a module".

Please post this elsewhere, however, I can tell you that you may or may not get someone to comment on it. No-one is going to want to stake their "reputation" on partial code, and probably not even full code. JMO.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©