We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Module Development: calling an external class

Development and Programming

vinci's avatar
vinci
85 posts
17 years ago
vinci's avatar vinci

Hello people. Sorry for posting into this part of the forum: Im waiting on my client to send me his EE licence so I can then post into the proper one - but need some feedback asap.

Im writing a module to compliment the member module - which will be a new module tab where you can fill out all of a members details in one hit from one page.

to make my life easier, id like to call functions from the cp.member.php file, such as update password etc. Im not advanced at php yet so might need someone to explain it to me if they dont mind taking the time to do so.

wouldnt it be something like:

require PATH_CORE.'core.update_password'.EXT;

but arent there other things I’d have to do in the new mcp.myModule.php? like declare the function etc..

any help appreciated 😊

Mod Edit: Moved to the Modules Technical Assistance forum.

       
Erin Dalzell's avatar
Erin Dalzell
790 posts
17 years ago
Erin Dalzell's avatar Erin Dalzell

I believe that is all you need to do vinci. Easy enough to try…just create a small PHP page, include that file and then make a call to one of its functions.

       
vinci's avatar
vinci
85 posts
17 years ago
vinci's avatar vinci

ok, ill try that… But im not sure how to require the file…

require PATH_CORE - outputs the path to core folder core.module - a core module? (so if it wasnt a core file it would be module_folder.module. EXT - cover any extension?

then how do you call a class/function?

also, what is a hook and how do you use a hook? i.e.

$edata = $EXT->call_extension('cp_members_member_create_start');
            if ($EXT->end_script === TRUE) return;
       
Erin Dalzell's avatar
Erin Dalzell
790 posts
17 years ago
Erin Dalzell's avatar Erin Dalzell

I can’t remember where those variables are set, but you can always just use the complete path and extension instead.

I would be careful of calling any functions in cp. as those look like they output to DSP (which is the Control Panel display).

As for calling a function, it would be something like this:

$m = new Member();
$m->function_to_call();

As for hooks, check out the docs

       
Erin Dalzell's avatar
Erin Dalzell
790 posts
17 years ago
Erin Dalzell's avatar Erin Dalzell
I can’t remember where those variables are set, but you can always just use the complete path and extension instead.

Those are set in core.system.php at line 162.

       
vinci's avatar
vinci
85 posts
17 years ago
vinci's avatar vinci
As for calling a function, it would be something like this:
$m = new Member();
$m->function_to_call();

Awesome thanks, thats what im after… but I get this:

Fatal error: Class ‘Member’ not found in /etc/staff/mcp.staff.php on line 320

I guess that means that im not declaring the class somewhere? (remember Im new to this)

       
Erin Dalzell's avatar
Erin Dalzell
790 posts
17 years ago
Erin Dalzell's avatar Erin Dalzell

I think you should review some PHP basics before going on. The questions you are asking have nothing to do with EE; they have to do with how to do PHP. I too, frequently get stuck on PHP issues.

Which file are you including? Which class are you trying to access? Which method are you trying to access?

       
vinci's avatar
vinci
85 posts
17 years ago
vinci's avatar vinci

im not THAT bad with php!

im trying to display the member form in cp.members.php

function staff_form($msg='')
    {
    global $DSP, $LANG, $DB, $IN, $VAL;
    require PATH_CP.'cp.members'.EXT;
    $MPR = new form;
    $MPR->create_member_profile(); 
    }
       
vinci's avatar
vinci
85 posts
17 years ago
vinci's avatar vinci

ok nevermind, i have it working now i had the class name wrong (didnt bother to check). but the next question is how to modify that called class and post into a different db?

       
Erin Dalzell's avatar
Erin Dalzell
790 posts
17 years ago
Erin Dalzell's avatar Erin Dalzell

Sounds like you want to extend a class.

       
vinci's avatar
vinci
85 posts
17 years ago
vinci's avatar vinci

thanks again, im finding classes hard to get my head around, and i keep coming back to tutorials… what I need to do, is once the form has been submitted and processed go to another form.

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra

Vinci,

I was following you until that last sentence.

You need to go to another form? Before you mentioned a need to post to another DB.

Care to give me more detail? (I feel like I ask this a lot).

Jamie

       
vinci's avatar
vinci
85 posts
17 years ago
vinci's avatar vinci

Originally i thought it would be possible to go to another form when submitting a new members, but after playing around and considering all of the requirements of the new form, it turned out that I had to basically have a whole new ‘pseudo-member’ function to work alongside the core member one.

it actually working quite well, but had to write an entire module for it.

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra

Glad you worked it out.

Jamie

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.