Page 1 of 1

inside the user component syntax help

Posted: Wed Dec 14, 2005 10:54 am
by mojito
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 :)

Re: inside the user component syntax help

Posted: Thu Dec 15, 2005 5:37 am
by RobS
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. 

Re: inside the user component syntax help

Posted: Thu Dec 15, 2005 10:32 pm
by mojito
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

Re: inside the user component syntax help

Posted: Fri Dec 16, 2005 3:48 am
by RobS
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. 

Re: inside the user component syntax help

Posted: Fri Dec 16, 2005 8:36 am
by mojito
Very well put, thanks. 8)

Re: inside the user component syntax help

Posted: Mon Dec 19, 2005 11:38 am
by mojito
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

Re: inside the user component syntax help

Posted: Mon Dec 19, 2005 11:41 am
by Predator
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

Re: inside the user component syntax help

Posted: Mon Dec 19, 2005 12:00 pm
by mojito
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

more pagination questions

Posted: Mon Dec 19, 2005 8:34 pm
by rontec76
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?

Re: inside the user component syntax help

Posted: Mon Dec 19, 2005 8:38 pm
by Predator
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.

Re: more pagination questions

Posted: Tue Dec 20, 2005 12:22 pm
by mojito
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.

Re: inside the user component syntax help

Posted: Wed Dec 21, 2005 7:06 am
by rontec76
sorry...

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

sorry to be in the wrong topic...