Welcome Guest, Not a member yet? Register   Sign In
Matchbox RC2

[eluser]zdknudsen[/eluser]
I sent you an answer as a reply to your e-mail stb74. Smile

[eluser]opel[/eluser]
Could you please post the answer publicly to the question above please ?

I have a global header, footer and side nav that I want to use across all my front end modules blog, news etc. I'm not sure how to set up matchbox so that I can call my global views without having to declare it in every controller.

Any help would be great.

Thanks

[eluser]zdknudsen[/eluser]
Basically, the previous posters' issue was that he had a layout view in the global views folder. That layout view then attempted to call a view in the modules view folder.

Now, the problem here is that whenever a resource is requsted, it is looked for in the directory of the caller (in this case, the caller is the layout view, calling a content view). However, since the layout view is in the global view folder, that's where the content view is searched for.

This is easily solved by adding the layout view file to the $config['callers'] array in the Matchbox configuration file. The array should contains strings with the filename. So if your layout view file is layout.php you could add 'layout.php' to the callers array. If you have multiple layout.php files, you could just add a bit of the path as well, e.g. '/application/views/layout.php'.

Feel free to ask if you have further problems.

[eluser]Armorfist[/eluser]
Hello,
This is in CI 1.7, its not out yet but it will soon.

Dont know if this is really a CI or MatchBox problem (although I suspect CI). The 1.7 version of CI has a new function in the Profiler library that is called "_compile_controller_info". I'm using matchbox 0.9.4 and when I enable the Profiler I get the following error:

Fatal error: Call to a member function fetch_class() on a non-object in Profiler.php on line 298

This line has the following code:

Code:
$output .= "<div style='color:#995300;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->router->fetch_class()."/".$this->CI->router->fetch_method()."</div>";

It seems like the router object isn't loaded when this function is called. A quick work around I made was extending the Profiler class and rewrite that function:

Code:
class MY_Profiler extends CI_Profiler {
    /**
     * Show the controller and function that were called
     *
     * @access    private
     * @return    string
     */    
    function _compile_cosntroller_info()
    {    
        $RTR =& load_class('Router');
        $output  = "\n\n";
        $output .= '<fieldset style="border:1px solid #995300;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
        $output .= "\n";
        $output .= '<legend style="color:#995300;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_controller_info').'&nbsp;&nbsp;</legend>';
        $output .= "\n";
        
        $output .= "<div style='color:#995300;font-weight:normal;padding:4px 0 4px 0'>".$RTR->fetch_class()."/".$RTR->fetch_method()."</div>";                

        
        $output .= "</fieldset>";

        return $output;    
    }
}

This works for now.

MatchBox has a modified Router lib, so I decided to ask here first before any place else to make sure it isn't a MatchBox problem. If its not, then I'll make a thread about it.

Thanks,
Frederico

[eluser]wiredesignz[/eluser]
There is no `router` object in CI proper, $RTR is a global object created by the CI bootstrapper.

Your fix works of course. But I think this is a bug and has been discussed elsewhere and needs an official fix.

[eluser]Armorfist[/eluser]
Thanks wiredesignz, going to wait for a final release then Wink

[eluser]dexcell[/eluser]
Hi, i also would like to contribute a little, maybe someone find it useful.

Because in CI 1.7 the libraries folder support sub directory, here is little fix in MatchBox.

Change _ci_load_class in Loader.php(matchbox)
Code:
function _ci_load_class($class, $params = NULL)
    {
        // Get the class name, and while we're at it trim any slashes.  
                // The directory path can be included as part of the class name,
                // but we don't want a leading slash
                $class = str_replace(EXT, '', trim($class, '/'));
                
                // Was the path included with the class name?
                // We look for a slash to determine this
                $subdir = '';
                if (strpos($class, '/') !== FALSE)
                {
                    // explode the path so we can separate the filename from the path
                    $x = explode('/', $class);    
                    
                    // Reset the $class variable now that we know the actual filename
                    $class = end($x);
                    
                    // Kill the filename from the array
                    unset($x[count($x)-1]);
                    
                    // Glue the path back together, sans filename
                    $subdir = implode($x, '/').'/';
                }

        // We'll test for both lowercase and capitalized versions of the file name
        foreach (array(ucfirst($class), strtolower($class)) as $class)
        {
            // {{{ Matchbox

            $module = $this->_matchbox->argument(2);

            if ($subclass = $this->_matchbox->find('libraries/'.$subdir.config_item('subclass_prefix') . $class . EXT, $module)) {

                $baseclass = $this->_matchbox->find('libraries/'.$class.EXT, $module, 2);

                // }}}

                if ( ! file_exists($baseclass))
                {
                    log_message('error', "Unable to load the requested class: ".$class);
                    show_error("Unable to load the requested class: ".$class);
                }

                // Safety:  Was the class already loaded by a previous call?
                if (in_array($subclass, $this->_ci_classes))
                {
                    $is_duplicate = TRUE;
                    log_message('debug', $class." class already loaded. Second attempt ignored.");
                    return;
                }

                include($baseclass);
                include($subclass);
                $this->_ci_classes[] = $subclass;

                // {{{ Matchbox

                return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $module);

                // }}}
            }

            // Lets search for the requested library file and load it.
            $is_duplicate = FALSE;

            // {{{ Matchbox

            if ($filepath = $this->_matchbox->find('libraries/'.$subdir.$class.EXT, $module, 2)) {
                if (in_array($class, $this->_ci_classes)) {
                    $is_duplicate = true;
                    log_message('debug', $class . ' class already loaded. Second attempt ignored.');
                    return;
                }

                include($filepath);
                $this->_ci_classes[] = $class;
                return $this->_ci_init_class($class, '', $params, $module);
            }

            // }}}

        } // END FOREACH
                
                // One last attempt.  Maybe the library is in a subdirectory, but it wasn't specified?
                if ($subdir == '')
                {
                    $path = strtolower($class).'/'.$class;
                    return $this->_ci_load_class($path, $params);
                }

        // If we got this far we were unable to find the requested class.
        // We do not issue errors if the load call failed due to a duplicate request
        if ($is_duplicate == FALSE)
        {
            log_message('error', "Unable to load the requested class: ".$class);
            show_error("Unable to load the requested class: ".$class);
        }
    }

[eluser]Johan André[/eluser]
I'm using Codeigniter 1.7 (updated from 1.6.3 using update instructions) along with Matchbox 0.94. The new form_validation does not seem to work properly. Is this because of Matchbox?

The validation itself seems to work, but the output of
Code:
validation_errors()
and
Code:
form_error('field_name')
is always blank, even though a validation error occured.

Someone wrote somewhere that the loaderclass in CI was changed in 1.7. Maybe that is causing trouble?

Great lib anyhow! I really can't develop without Matchbox (and DrF's Reverse routing) anymore. Smile

[eluser]wiredesignz[/eluser]
@johan André, I'm not sure if Zach intends to update Matchbox library loader to CI 1.7, However Modular Extensions 5.1 gives you the same modularity as Matchbox and is CI 1.7 compatible.

[eluser]Johan André[/eluser]
Oki!
Can I just replace Matchbox with ME5.1? I'm pretty far into a project in which I've already developed alot of modules...




Theme © iAndrew 2016 - Forum software by © MyBB