inside the user component syntax help

For Joomla! 1.0 Coding related discussions.
Locked
User avatar
mojito
Joomla! Guru
Joomla! Guru
Posts: 755
Joined: Wed Sep 07, 2005 10:18 pm
Location: London
Contact:

inside the user component syntax help

Post by mojito » Wed Dec 14, 2005 10:54 am

to do with users in this case

function userEdit( $row, $option, $submitvalue, &$params )

I've never come across this syntax for an argument, how is it used? what will it change?


also what does this do

require_once ( $mainframe->getPath( 'front_html' ) );

thanks
m :)
Last edited by mojito on Wed Dec 14, 2005 11:42 am, edited 1 time in total.
I am a freelance SEO (https://cambs.eu) web designer and developer working with Wordpress and Joomla since Mambo.

User avatar
RobS
Joomla! Ace
Joomla! Ace
Posts: 1366
Joined: Mon Dec 05, 2005 10:17 am
Location: New Orleans, LA, USA
Contact:

Re: inside the user component syntax help

Post by RobS » Thu Dec 15, 2005 5:37 am

In your first question, are you asking how to pass an argument to a function?  Or something else?

As for the second question.

require_once ( $mainframe->getPath( 'front_html' ) );

Is saying that this file, is trying to include another file, which is the nave of the component.html.php.  front_html is basically an internal variable constant referring to the components .html.php file, which is used normally to do the actual html presentation. 
Rob Schley - Open Source Matters
Webimagery - http://www.webimagery.net/ - Professional Consulting Services
JXtended - http://www.jxtended.com/ - Free and Commercial Joomla! Extensions

User avatar
mojito
Joomla! Guru
Joomla! Guru
Posts: 755
Joined: Wed Sep 07, 2005 10:18 pm
Location: London
Contact:

Re: inside the user component syntax help

Post by mojito » Thu Dec 15, 2005 10:32 pm

That helps me a lot as I couldnt see any includes for the components constructed with html.php files and .php files, that must be the line.

For the first part the bit I dont get is the "&" just before the argument$params, does this concatenate the current $params with new $params ?

thanks

c
I am a freelance SEO (https://cambs.eu) web designer and developer working with Wordpress and Joomla since Mambo.

User avatar
RobS
Joomla! Ace
Joomla! Ace
Posts: 1366
Joined: Mon Dec 05, 2005 10:17 am
Location: New Orleans, LA, USA
Contact:

Re: inside the user component syntax help

Post by RobS » Fri Dec 16, 2005 3:48 am

A '&' in php is actually used to pass a variable as a reference, so &$params means pass the memory location of $params, instead of making a copy of $params for that function.  It is intended to cut down on unnecessary memory usage, and to make your program faster.  However, it is optional.  It would be ok to pass $params as the argument, however, if you do any changes to the $params variable inside your function, you will have to return $params upon completion, and update it outside of the function.  So, in most cases, it is easier and faster to pass it as a reference using the & operator.  Of course, there are instances when this is not ideal, and it is better to pass a copy of %params instead of having the function use a global $params.

Hope that helps. 
Rob Schley - Open Source Matters
Webimagery - http://www.webimagery.net/ - Professional Consulting Services
JXtended - http://www.jxtended.com/ - Free and Commercial Joomla! Extensions

User avatar
mojito
Joomla! Guru
Joomla! Guru
Posts: 755
Joined: Wed Sep 07, 2005 10:18 pm
Location: London
Contact:

Re: inside the user component syntax help

Post by mojito » Fri Dec 16, 2005 8:36 am

Very well put, thanks. 8)
I am a freelance SEO (https://cambs.eu) web designer and developer working with Wordpress and Joomla since Mambo.

User avatar
mojito
Joomla! Guru
Joomla! Guru
Posts: 755
Joined: Wed Sep 07, 2005 10:18 pm
Location: London
Contact:

Re: inside the user component syntax help

Post by mojito » Mon Dec 19, 2005 11:38 am

RobS wrote: In your first question, are you asking how to pass an argument to a function?  Or something else?

As for the second question.

require_once ( $mainframe->getPath( 'front_html' ) );

Is saying that this file, is trying to include another file, which is the nave of the component.html.php.  front_html is basically an internal variable constant referring to the components .html.php file, which is used normally to do the actual html presentation. 
Im getting the following error when trying to use the above instead of just including (in this case) "display.html.php";

Code: Select all

Fatal error: Call to a member function getPath() on a non-object in C:\Uniform3_1_1s\www\landedAt\components\com_journal\journal.php on line 113
the object doesnt exist, ive tried the line global $mainframe which doesnt work.
thanks for any help
I am a freelance SEO (https://cambs.eu) web designer and developer working with Wordpress and Joomla since Mambo.

User avatar
Predator
Joomla! Ace
Joomla! Ace
Posts: 1823
Joined: Wed Aug 17, 2005 10:12 pm
Location: Germany-Bad Abbach
Contact:

Re: inside the user component syntax help

Post by Predator » Mon Dec 19, 2005 11:41 am

mojito wrote:
RobS wrote: In your first question, are you asking how to pass an argument to a function?  Or something else?

As for the second question.

require_once ( $mainframe->getPath( 'front_html' ) );

Is saying that this file, is trying to include another file, which is the nave of the component.html.php.  front_html is basically an internal variable constant referring to the components .html.php file, which is used normally to do the actual html presentation. 
Im getting the following error when trying to use the above instead of just including (in this case) "display.html.php";

Code: Select all

Fatal error: Call to a member function getPath() on a non-object in C:\Uniform3_1_1s\www\landedAt\components\com_journal\journal.php on line 113
the object doesnt exist, ive tried the line global $mainframe which doesnt work.
thanks for any help
Your component is named com_journal so the display.html.php has to renamed to journal.html.php
The "Humor, Fun and Games" forum has  more than 2500 Posts, so why not build a "Humor, Fun and Games Working" Group?
.....
Malicious tongues say we have this WG right from the start, they call it core team :D

User avatar
mojito
Joomla! Guru
Joomla! Guru
Posts: 755
Joined: Wed Sep 07, 2005 10:18 pm
Location: London
Contact:

Re: inside the user component syntax help

Post by mojito » Mon Dec 19, 2005 12:00 pm

But it is a separate template from journal.html.php. I want to have many templates for this component. Does this mean that I just should use

require(display.html.php);

is there anything wrong with that cause this works.

thanks
I am a freelance SEO (https://cambs.eu) web designer and developer working with Wordpress and Joomla since Mambo.

User avatar
rontec76
Joomla! Intern
Joomla! Intern
Posts: 85
Joined: Tue Aug 23, 2005 4:27 am
Contact:

more pagination questions

Post by rontec76 » Mon Dec 19, 2005 8:34 pm

Ian (or anyone else),

Is there a fairly straight forward way, or some class already defined in Joomla that I can use to dump my $_POST vars into an array and use sessions to pass them along in the component?

that way I don't have to rely passing everything along via the URL?

User avatar
Predator
Joomla! Ace
Joomla! Ace
Posts: 1823
Joined: Wed Aug 17, 2005 10:12 pm
Location: Germany-Bad Abbach
Contact:

Re: inside the user component syntax help

Post by Predator » Mon Dec 19, 2005 8:38 pm

mojito wrote: But it is a separate template from journal.html.php. I want to have many templates for this component. Does this mean that I just should use

require(display.html.php);

is there anything wrong with that cause this works.

thanks
The getPath directly by using with front_html, class etc is limit to only this files, for other you need to use require.
The "Humor, Fun and Games" forum has  more than 2500 Posts, so why not build a "Humor, Fun and Games Working" Group?
.....
Malicious tongues say we have this WG right from the start, they call it core team :D

User avatar
mojito
Joomla! Guru
Joomla! Guru
Posts: 755
Joined: Wed Sep 07, 2005 10:18 pm
Location: London
Contact:

Re: more pagination questions

Post by mojito » Tue Dec 20, 2005 12:22 pm

rontec76 wrote: Ian (or anyone else),

Is there a fairly straight forward way, or some class already defined in Joomla that I can use to dump my $_POST vars into an array and use sessions to pass them along in the component?

that way I don't have to rely passing everything along via the URL?
I would like to know more on that as well here http://forum.joomla.org/index.php/topic,23929.0.html so we dont go off topic.
I am a freelance SEO (https://cambs.eu) web designer and developer working with Wordpress and Joomla since Mambo.

User avatar
rontec76
Joomla! Intern
Joomla! Intern
Posts: 85
Joined: Tue Aug 23, 2005 4:27 am
Contact:

Re: inside the user component syntax help

Post by rontec76 » Wed Dec 21, 2005 7:06 am

sorry...

somehow in one of late nights i accidentally posted this here...

sorry to be in the wrong topic...


Locked

Return to “Joomla! 1.0 Coding”