Breadcrumbs for a module needs home url changed to module home url

I have this code:


	'Developers'=>array(Yii::t('app', 'index')),

	Yii::t('app', 'Manage'),


This creates a breadcrum like this:

Home » Developers » Manage

Where Home links to site home, and I want to link to the module home.

Developers links to the correct url.

What should I change?

Can I set this per module?

Yeah man, just define the breadcrumb widget in your module layout file.

I know how to use the widget, but I don’t know how to set in one place the homeUrl of the breadcrumb widget.

Could you please show me how can I define the homeUrl for a given module?

There are many options.

You can create a new template for the module, and defining in this new template the widget, so you will have complete control on all properties.

You can add a new property on Controller.php (located under protected/components):

public $homeUrl="/"

And use this for configure the home url in the layout/main.php.

In the controllers of the module you can set the home url to be the home of the module.

I’ve added this and it’s not recognized by the breadcrumbs

class AdminModule extends CWebModule {

    public $homeUrl="/admin/";


in the layout you can access only properties defined in the controller, not included the variable passed to the view file

and you use it like this in the layout file:

echo $this->homeUrl;

in your main layout


    	$this->widget('zii.widgets.CBreadcrumbs', array(


      	'homeLink'=>(isset($this->homeUrl) ? $this->homeUrl : '/')


you can find more options here

I’ve tried to put this in the theme’s main.php file

per like this:

<?php $this->widget('zii.widgets.CBreadcrumbs', array(



but doesn’t worked out either

I want to set globally, not by editing each file where I’ve used this.

edit the default homeLink in framework/zii/widgets/CBreadcrumbs.php and you can do that

I’ve found a documentation node that says how to customize widgets per theme

it’s described here:

but that doesn’t work out for me, what I am doing wrong?

how can we know if you dont post your code?

it’s in post #10 as mentioned earlier

as its explained in the link you sent, you must change in the main config file (probably configs/main.php)

something like:

return array(

    //other config


        //other components










Nice idea, Gustavo.

Maybe in adminModule is possible to do something like:

	public function beforeControllerAction($controller, $action)


		if(parent::beforeControllerAction($controller, $action))


			Yii::app()->widgetFactory->widgets['CBreadcrumbs']=array( 'homeLink'=>array('/admin'));

			return true;



			return false;


I never tried it before, but according to the doc looks possible.

Let us know if it works.

Also is better to write array(’/admin’) instead of ‘/admin’, in this case the base url will be added if needed (and will work even in case of routig with parameters)

The correct way is:

	public function beforeControllerAction($controller, $action)


		if(parent::beforeControllerAction($controller, $action))


			Yii::app()->widgetFactory->widgets['CBreadcrumbs']=array( 'homeLink'=>CHtml::link('Home', array('/admin')));


			return true;



			return false;


Not sure if this helps, but perhaps put a Controller.php in your module’s ‘components’ folder and define a public $breadcrumbs object in there? Your module’s controllers should automatically extend from this controller class.

– thnkx