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()->pendingCommentCount . ')'; ?></li>
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:
$this->menu=array(
array('label'=>'Create Blog', 'url'=>array('create')),
array('label'=>'Manage Blog', 'url'=>array('admin')),
array('label'=>'Approve Comments', 'url'=>'blogComment/index', 'itemOptions'=>array('('.BlogComment::model()->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">
<ul class="operations" id="yw3">
<li><a href="/test/blog/create">Create Blog</a></li>
<li><a href="/test/blog/admin">Manage Blog</a></li>
<li 0="(4)"><a href="blogComment/index">Approve Comments</a></li>
</ul></div>
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!