Error on loading website (language)

Hi,

When I go to my website I have a blanco page with this error:
Fatal error: Cannot redeclare class Asset in …/kirby/branches/multilang.php on line 6

How can I resolve this?

What Kirby version are you on? What PHP version? What is in your config?

Kirby version: 2.5.6

My config.php

    // Languages
    c::set('date.handler', 'strftime'); 
    c::set('lang.detect', true);
    c::set('languages', array(
    	array(
    		'code'		=> 'nl',
    		'name'		=> 'NL',
    		'default'   => true,
    		'locale'	    => 'nl_NL',
    		'url'	    => '/'
    	),
    	array(
    		'code'		=> 'fr',
    		'name'		=> 'FR',
    		'locale'	    => 'fr_FR',
    		'url'		=> '/fr'
    	)
    ));

It that really all that is in your config?

This is it all:

 <?php

    /*

    ---------------------------------------
    License Setup
    ---------------------------------------

    Please add your license key, which you've received
    via email after purchasing Kirby on http://getkirby.com/buy

    It is not permitted to run a public website without a
    valid license key. Please read the End User License Agreement
    for more information: http://getkirby.com/license

    */

    c::set('license', 'put your license key here');

    /*

    ---------------------------------------
    Kirby Configuration
    ---------------------------------------

    By default you don't have to configure anything to
    make Kirby work. For more fine-grained configuration
    of the system, please check out http://getkirby.com/docs/advanced/options

    */

    // Ignore cache sitemap
    c::set('cache.ignore', array('sitemap'));

    // Languages
    c::set('date.handler', 'strftime'); 
    c::set('lang.detect', true);
    c::set('languages', array(
    	array(
    		'code'		=> 'nl',
    		'name'		=> 'NL',
    		'default'   => true,
    		'locale'	    => 'nl_NL',
    		'url'	    => '/'
    	),
    	array(
    		'code'		=> 'fr',
    		'name'		=> 'FR',
    		'locale'	    => 'fr_FR',
    		'url'		=> '/fr'
    	)
    ));

    // Thumbs
    c::set('thumbs.destination', function($thumb) {
    	$destination = new Obj();

    	// Create filename (copied from /kirby/toolkit/lib/thumb.php)
    	$destination->filename = str::template($thumb->options['filename'], array(
    		'extension'		=> $thumb->source->extension(),
    		'name'			=> $thumb->source->name(),
    		'filename'		=> $thumb->source->filename(),
    		'safeName'		=> f::safeName($thumb->source->name()),
    		'safeFilename'  => f::safeName($thumb->source->name()) . '.' . $thumb->extension(),
    		'width'			=> $thumb->options['width'],
    		'height'			=> $thumb->options['height'],
    		'hash'			=> md5($thumb->source->root() . $thumb->settingsIdentifier())
    	));

    	// Thumbnail foldername
    	// TODO: Create setting like c::set('thumbs.subdirectory', 'thumbs');
    	$t = 'thumbs';

    	// Recalc URL
    	$urlPath = str_replace($thumb->source->filename(), "", $thumb->url()) . $t;
    	$destination->url	= $urlPath . '/' . $destination->filename;

    	// Create Outputdirectory if it doesn't exist
    	$outputFolder = new Folder($thumb->dir() . DS . $t);
    	if (!$outputFolder->exists())
    	$outputFolder->make(true);

    	$destination->root = $outputFolder . DS . $destination->filename;

    	return $destination;
    });

    // Prevent Kirby from acknowledging the thumbs directory as a page.
    c::set('content.file.ignore',array('thumbs'));

    // Shrink large images on upload
    kirby()->hook('panel.file.upload', 'shrinkImage');
    kirby()->hook('panel.file.replace', 'shrinkImage');
    function shrinkImage($file, $maxDimension = 2000) {
    	try {
    		if ($file->type() == 'image' and ($file->width() > $maxDimension or $file->height() > $maxDimension)) {
    			$originalPath = $file->dir().'/'.$file->filename();
    			$resized = $file->resize($maxDimension,$maxDimension);
    			$resizedPath = $resized->dir().'/'.$resized->filename();
    			copy($resizedPath, $originalPath);
    			unlink($resizedPath);
    		}
    	} catch(Exception $e) {
    		return response::error($e->getMessage());
    	}
    }

I’ve got the same error message on my multilingual website (Kirby 2.5.7)

There is an issue on github :

Well, yes, but @tutchi said he is using K 2.5.6 and there is no call to kirby() in his config…

In a fresh 2.5.6 langkit with the above config.php, I can’t reproduce the error, unless I make a call to site() like this:

$site = site();

And the above config does not throw an error in a 2.5.7 langkit either.

What plugins are you using, @tutchi?

I’m using these plugins:

  • Autopublish
  • kirby-ga
  • minifyhtml
  • phpmailer
  • uniform

Is that your only config file? Are you using the recommended setting

if (kirby()->site()->user()) c::set('MinifyHTML', false);

anywhere?

BTW, it helps if

  • you use three backticks before and after code when posting code block
  • you post links to the plugins you mention

I found the problem.

// Client dashboard
if(kirby()->site()->user() && kirby()->site()->user()->role() <> 'admin') {
	c::set('panel.stylesheet', 'assets/css/custom-panel.css');
}

What is the error?

Where is this code? In another config file?

The problem is the call to Kirby() in the config file. It is not possible in a multilang environment, as the GitHub error shows.