Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » Chameleon / ChameleonLite
- » Chameleon
- » [solved] Configuring menu so that it...
[solved] Configuring menu so that it shows number of new messages
[solved] Configuring menu so that it shows number of new messages
Hi,
I am using the latest version Chameleon on a Joomla 3.2 website, which also has Community Builder and uddeIM installed.
I configured Chameleon so that a different menu is presented to logged in users. One of the items in this menu is "Messages".
Whenever there is a new, unread message waiting for the user, I would like to display to the right of the menu item the number of unread messages waiting, in parenthesis, like this... Messages (3)
I found an earlier forum post where you explained how to do this:
http://www.metamodpro.com/forums/topic?id=876
However, when I tried it, I got an system error message on a white screen and nothing else would display. Perhaps the error came because the post was for a J1.5 website, where I am running J3.2
Can you please explain what I need to do to achieve this?
Many thanks!
Hector
18-Dec-13 00:30:20
Re: [solved] Configuring menu so that it shows number of new messages
Hi Hector,
you are right, the original post was for a Joomla 1.5 install. I've done some updating so it can work on J2.5, though I have not been able to test the part of it that detects the uddeIM database. Try this however: (this requires the full version of Chameleon for Joomla 2.5)
Code:
$menuid = XXX; // replace XXX with the id of the menu item to change
$udduserid = $user->id;
$uddsql="SEL" . "ECT count(a.id) FROM #_" . "_uddeim AS a WHERE `a`.`delayed`=0 AND a.totrash=0 AND a.toread=0 AND a.toid=".(int)$udduserid;
$db->setQuery($uddsql);
$uddresult=(int)$db->loadResult();
$message = "Private Messages";
if ($uddresult > 0) $message .= " ($uddresult new)";
$allmenus = JFactory::getApplication()->getMenu();
$rProperty = new ReflectionProperty($allmenus, '_items');
$rProperty->setAccessible(true);
$items = $rProperty->getValue($allmenus);
$items[$menuid]->title = $message;
Re: [solved] Configuring menu so that it shows number of new messages
Excellent - glad that worked for you. This is quite a powerful technique. [wondering out loud if this would be a candidate for a Chameleon "action": to change a particular menu item name. But exactly what kind of options to provide, I don't know]
Thanks for reporting back,
Stephen
Re: [solved] Configuring menu so that it shows number of new messages
Yes, as always that's the predicament. A simple text rename would be one thing, but it would not have helped in your case as you needed a very specific value from the database to populate it with, and then only if it was >0. So PHP is really the easiest way to implement it, but it's not very user friendly.
Oh well. At least we made it do exactly what you wanted.
Re: [solved] Configuring menu so that it shows number of new messages
Hi Maranatha,
In general, to achieve the type of results you are looking for, you will be looking for ways to affect the HTML and CSS of the page. One approach would be to identify from the HTML output of the page, the exact HTML that your menu item contains. e.g. it may look like:
<li class="item-444"><a href="/sample-sites" >Sample Sites</a></li>
So, you could use the find-and-replace action in Chameleon to search for:
<li class="item-444">
and replace it with:
<li class="item-444"><span style="color:red">•</span>
(obviously, you only want to do that on the pages where you are doing the original action of changing the menu item text, so do that in your existing rule)
If you want to change the background colour of the menu tab you'll need to investigate what CSS is currently applied to that menu tab (will be different for every template). Then in the succeed action you could output some CSS code to target that tab. For the example above it may be as simple as the following:
li.item-444 {background-color:red;}
Hope that helps,
Stephen
- Index
- » Chameleon / ChameleonLite
- » Chameleon
- » [solved] Configuring menu so that it...
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Posts this week:
- 2
- User Info:
- Total Users:
- 7627
- Newest User:
- rudys68879
- Members Online:
- 0
- Guests Online:
- 184
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked