Blog Tutorial - itemOptions CMenu

Hello fellow Yiiers!

I’ve been working through the blog tutorial and got to the usermenu portlet section and am trying to modify the content a bit.

By default the portlet creates a menu and uses the following code:

<li><?php echo CHtml::link(‘Approve Comments’,array(‘comment/index’))

    . ' (' . Comment::model()-&gt;pendingCommentCount . ')'; ?&gt;&lt;/li&gt;

To create output (in html) similar to the following:

<li><a href="/test/blogComment/index">Approve Comments</a> (4)</li>

I am trying to mimic this output, but doing so through a CMenu item.

I have the following in one of my views:


array('label'=&gt;'Create Blog', 'url'=&gt;array('create')),

array('label'=&gt;'Manage Blog', 'url'=&gt;array('admin')),

array('label'=&gt;'Approve Comments', 'url'=&gt;'blogComment/index', 'itemOptions'=&gt;array('('.BlogComment::model()-&gt;pendingCommentCount.')')),


The menu is created and with the correct labels (create blog, manage blog, approve comments) however the “(4)” that is generated with the portlet code I cannot get to generate in the CMenu code.

The raw html of the CMenu is:

<div class="portlet-content">

&lt;ul class=&quot;operations&quot; id=&quot;yw3&quot;&gt;

&lt;li&gt;&lt;a href=&quot;/test/blog/create&quot;&gt;Create Blog&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href=&quot;/test/blog/admin&quot;&gt;Manage Blog&lt;/a&gt;&lt;/li&gt;

&lt;li 0=&quot;(4)&quot;&gt;&lt;a href=&quot;blogComment/index&quot;&gt;Approve Comments&lt;/a&gt;&lt;/li&gt;


So the “(4)” is being rendered, just not in the correct place. I’ve tried both linkOptions and itemOptions and neither seem to work.

Any suggestions?

Thank you!

Any suggestions?