Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li><p>If you are using the latest version of <a href="http://www.yiiframework.com/news/55/yii-php-framework-1-1-11-is-released/" rel="noreferrer" title="http://www.yiiframework.com/news/55/yii-php-framework-1-1-11-is-released/">Yii (1.1.11)</a>, then you have a few <em>new</em> options in <a href="http://www.yiiframework.com/doc/api/1.1/CBreadcrumbs" rel="noreferrer" title="http://www.yiiframework.com/doc/api/1.1/CBreadcrumbs">CBreadcrumbs</a>, namely: <code>activeLinkTemplate</code> and <code>inactiveLinkTemplate</code> and using these (and also <code>tagName</code>) you can easily achieve your requirement.</p> <p>You just need to add values for these options, in the file where you are including the breadcrumb widget, by default, it's in a layout file : <em>protected/views/layouts/main.php</em> , like this:</p> <pre><code>&lt;?php if(isset($this-&gt;breadcrumbs)):?&gt; &lt;?php $this-&gt;widget('zii.widgets.CBreadcrumbs', array( 'links'=&gt;$this-&gt;breadcrumbs, 'tagName'=&gt;'ul', // will change the container to ul 'activeLinkTemplate'=&gt;'&lt;li&gt;&lt;a href="{url}"&gt;{label}&lt;/a&gt;&lt;/li&gt;', // will generate the clickable breadcrumb links 'inactiveLinkTemplate'=&gt;'&lt;li&gt;{label}&lt;/li&gt;', // will generate the current page url : &lt;li&gt;News&lt;/li&gt; 'homeLink'=&gt;'&lt;li&gt;&lt;a href="'.Yii::app()-&gt;homeUrl.'"&gt;Home&lt;/a&gt;&lt;/li&gt;' // will generate your homeurl item : &lt;li&gt;&lt;a href="/dr/dr/public_html/"&gt;Home&lt;/a&gt;&lt;/li&gt; )); ?&gt;&lt;!-- breadcrumbs --&gt; &lt;?php endif?&gt; </code></pre> <p><code>'activeLinkTemplate'</code> generates links for active/clickable links, and <code>'inactiveLinkTemplate'</code> generates the current url which is not clickable and has no url.</p> <p><code>{url}</code> and <code>{label}</code> are the <em>url</em> and <em>label</em> values provided by each view's breadcrumb object. eg:-</p> <pre><code>// in some view.php file, you'll see this $this-&gt;breadcrumbs=array( // array is label=&gt;url 'Label1'=&gt;array('route1'), 'Label2'=&gt;array('route2'), 'Label3', ); </code></pre></li> <li><p>If you are using versions before 1.1.11 then you'll have to <code>extend</code> the CBreadcrumbs class and modify the <code>run()</code> method to output breadcrumbs, enclosed in <code>&lt;li&gt;</code>. Once you see the existing <code>run()</code> method it'll become fairly clear to you how to do it.</p></li> </ol> <p><strong>Edit:</strong></p> <p>Missed out how to add the css class. You can do this by adding a class key-value in the htmlOptions array for this widget :</p> <pre><code>&lt;?php $this-&gt;widget('zii.widgets.CBreadcrumbs', array( 'links'=&gt;$this-&gt;breadcrumbs, 'tagName'=&gt;'ul', // will change the container to ul 'htmlOptions'=&gt;array('class'=&gt;'menu'), // ... rest of the code ... )); ?&gt;&lt;!-- breadcrumbs --&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload