Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter
Support for Vanilla Forums Cloud product

In this Discussion

Follow Us


CountDiscussions, CountBookmarks, CountDrafts, and CountNotifications Don't work.

edited April 2012 in Questions

I'm still trying to get used to Smarty so bear with me but I have the following code in my 'default.master.tpl'...

{if $User.SignedIn}
    <li>
    <a href="{link path="messages/inbox"}">Inbox
    {if $User.CountUnreadConversations} <span>{$User.CountUnreadConversations}</span>{/if}</a>
    </li>
    <li>
    <a href="{link path="profile"}">Your Profile (<em>{$User.Name}</em>)
    {if $User.CountNotifications > 0}<span>{$User.CountNotifications}</span>{/if}</a>
    </li>
    <li>
    <a href="{link path="discussions/mine"}">Your Discussions
    {if $User.CountDiscussions > 0}<span>{$User.CountDiscussions}</span>{/if}</a>
    </li>
    <li>
    <a href="{link path="discussions/bookmarked"}">Bookmarks
    {if $User.CountBookmarks > 0}<span>{$User.CountBookmarks}</span>{/if}</a>
    </li>
    <li>
    <a href="{link path="drafts"}">Drafts
    {if $User.CountDrafts > 0} <span>{$User.CountDrafts}</span>{/if}</a>
    </li>
    {if CheckPermission('Garden.Settings.Manage')}
    <li><a href="{link path="dashboard/settings"}">Dashboard</a></li>
    {/if}
{/if}

But it doesn't seem to show the number in the header? I am testing this out so I made sure I had bookmarks, drafts etc. Which DO show up in the normal discussions tabs.

Is {$User.CountDiscussions}, {$User.CountBookmarks}, {$User.CountNotifications}, etc. not the right way to do it?

Answers

  • I figured this out. I had to add it to class.smarty.php so it knew those "shortcodes"!

  • 422422 Developer MVP

    Afaik, each tpl file has a corresponding php file. Thats how smarty compiles. Thanks for posting your fix, would be nice for you to post the code you added also ( to the php file ) if nothing else but for posterity.

    Ste

    422 Real Estate Australia , now open Check it out

  • 422 said: Afaik, each tpl file has a corresponding php file. Thats how smarty compiles.

    Hmmm, I'm not sure about that or not to be honest? Again, I don't know much about smarty and how it works, all I know is that when I added code to "class.smarty.php" I got my stuff working! haha :)

    An ywho, here is the updated php file for "class.smarty.php" (located inside the directory /library/core/): http://pastebin.com/YuC0vB5K - I modified lines 49-54! :)

    422peregrine
  • nice documentation. thx.

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

  • No problem! Glad I could help.

  • Line 48 should be

            'CountNotifications' => (int)GetValue('CountNotifications', $Session->User, 0),
    

    not

            'CountNotifications' => (int)GetValue('CountNotifications', $Session->User->CountNotifications, 0),
    
Sign In or Register to comment.