21293 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1186 Views |
-
getting variable from another class

25 February 2009 at 11:02am Last edited: 25 February 2009 11:57am
I need to get a variable from another class in the same file, for a widget I am making.
GalleryUpload.php
class GalleryUpload extends Widget {
static $db = array(
"GalleryName" => "varchar", //gallery name
"Location" => "varchar", //location of folder to upload files to
"Redirect" => "varchar" //landing page after user uploads image
);
...
}
class GalleryUpload_Controller extends Controller {
...
function doForm($data, $form) {
$file = new File();
$file->loadUploaded($_FILES['FileTypeID'], "/galleries/" . $this->Location ); // HERE
// Redirect to a page thanking people for registering
Director::redirect( $this->Redirect ); // HERE
}}
On the lines that say "//HERE" are the variables I need from above. I have tried several things, just to see if it would work, but no luck.
How could I get the variables from "class GalleryUpload" into "class GalleryUpload_Controller"?
-
Re: getting variable from another class

25 February 2009 at 12:14pm
Just use $this-> GalleryName or whatever. Variables from the dataobject are available from it's controller.
-
Re: getting variable from another class

25 February 2009 at 1:21pm Last edited: 25 February 2009 1:39pm
That was the first thing I tried, but $this->Anything will always be blank. Is there another way?
*edit*
It is a submit form, so I am going to try session variables to set $this->Location, and $this->Redirect, and see how that works out. I would still like some better ideas though.*edit*
Sessions worked
| 1186 Views | ||
|
Page:
1
|
Go to Top |


