Part of the EllisLab Network
   
2 of 12
2
Wick 0.91 - Discontinued
Posted: 26 May 2008 06:45 AM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  369
Joined  06-16-2006

Yes, I actually took a quick look at using Wick with Matchbox yesterday, and it only takes a single line of code to make it work. Untill I release the next version of Matchbox (might take a while, I’m pretty busy with school, and most of the examns are next week) you can add this line to the Router.php file:

...

function 
_validate_request($segments)
{
    
// {{{ Matchbox
    
$this->_called 0// <-- Insert this line (at line 239)

    
foreach($this->_matchbox->directory_array() as $directory{

... 

That should do the trick. Please let me know if it works.

 Signature 

Best regards. Zacharias.
Matchbox (Modular Separation) | Wick (Controller Loader)

Profile
 
 
Posted: 26 May 2008 07:09 AM   [ Ignore ]   [ # 12 ]  
Grad Student
Rank
Total Posts:  84
Joined  08-23-2007

Works like a charm! Thanx a lot!

Profile
 
 
Posted: 26 May 2008 07:22 AM   [ Ignore ]   [ # 13 ]  
Grad Student
Rank
Total Posts:  84
Joined  08-23-2007

Short silly question: how can I pass variables from one controller to another? To my understanding I would add them like this (url-style):

$this->load->controller('contoller/method/var1/var2'); 

But looking at the code, this doesn’t seem to be the case wink Should I use an array to do this?

Profile
 
 
Posted: 26 May 2008 08:56 AM   [ Ignore ]   [ # 14 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  369
Joined  06-16-2006

Have you tried your idea that is adding them like segments? It might just work.

 Signature 

Best regards. Zacharias.
Matchbox (Modular Separation) | Wick (Controller Loader)

Profile
 
 
Posted: 26 May 2008 09:06 AM   [ Ignore ]   [ # 15 ]  
Grad Student
Rank
Total Posts:  84
Joined  08-23-2007

I tried that, but can’t get it to work. Are you saying it SHOULD work or it COULD work? wink

Profile
 
 
Posted: 26 May 2008 09:11 AM   [ Ignore ]   [ # 16 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  369
Joined  06-16-2006

As mentioned I haven’t had time to test my little library, so I am still unaware of how it works exactly.

Come to think of it, there might be problems, since the uri library will either need to keep the previous segments or be overwritten with the ones from the new controllers, unless I can find a way to have seperate uri library instances for each controller. I’ll look into it when I have the time. Untill then, you could always put them somewhere in the codeigniter object, either in a library or directy in $this->myvariable.

 Signature 

Best regards. Zacharias.
Matchbox (Modular Separation) | Wick (Controller Loader)

Profile
 
 
Posted: 26 May 2008 09:58 AM   [ Ignore ]   [ # 17 ]  
Grad Student
Rank
Total Posts:  84
Joined  08-23-2007

I tried the $this->variable approach as well, but it seems that $this refers to the current controller, so I get “Undefined property: Somecontroller::$id”.

Anyway, I’ll wait till you have time to look at it. For now, good luck with your exams, and thanks for this very interesting library!

Profile
 
 
Posted: 27 May 2008 03:46 AM   [ Ignore ]   [ # 18 ]  
Grad Student
Rank
Total Posts:  47
Joined  11-25-2007

Zacharias, Here something for you to try after your school exams wink. If you are using a Windows PC, try http://www.en.wampserver.com/ instead of XAMPP. Currently, Wampserver only for Windows. Most impotently you can easily change the APACHE, MySQL and PHP versions on your LAMP by pressing few mouse clicks with Wampserver. This is very helpful for code testing.

BTW, I used XAMPP before and it is really good. However, it cannot change my LAMP versions as simple as Wampserver do.

Profile
 
 
Posted: 27 May 2008 10:15 AM   [ Ignore ]   [ # 19 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  593
Joined  02-04-2008

Does it just re-route the request or do variables set in the initial controller carry through?

Profile
 
 
Posted: 27 May 2008 06:26 PM   [ Ignore ]   [ # 20 ]  
Grad Student
Rank
Total Posts:  84
Joined  08-23-2007

Today I played with the code a little to see if I could implement url-style arguments. And while I was working on it, I also changed the array-style arguments implementation, because I didn’t understand how to call the controller and method in the default implementation smile

Now you can choose if you want to call the controller url-style:

$this->load->controller('controller/method/var1/var2/var3'); // supports unlimited amount of parameters 

or array-style:

$params = array('var1'=>'value1''var2'=>'value2''var3'=>'value3');
$this->load->controller('controller/method/'$params); 

Here’s the code:

// from line 59

function load($uri$params=''// <- this changed
    
{
        
        $uri 
explode('/'$uri);
        

        
$router = &load;_class('Router');
        
$router->_set_request($uri);

        include(
APPPATH 'controllers/' $router->fetch_directory() . $router->fetch_class() . EXT);

        
$class  $router->fetch_class();
        
$method $router->fetch_method();
        
    
        
$controller = new $class();
        
// changed below

        
if(!$params){
        
        
// get arguments from uri
        
$params array_slice($uri2);
    
        
call_user_func_array(array($controller$method), $params);    
                
        
}
        
else // user defined array-style arguments
        
{
            $controller
->$method($params);
        
}
        
    
    } 

Hopefully someone finds it useful smile

Profile
 
 
   
2 of 12
2
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 149020 Total Logged-in Users: 35
Total Topics: 103296 Total Anonymous Users: 3
Total Replies: 516931 Total Guests: 310
Total Posts: 620227    
Members ( View Memberlist )