Display view count when logged in as admin but not for visitors

BillWill

Joined: 2008-08-28
Posts: 55
Posted: Sat, 2009-09-12 10:31

Hello -

I'm running v2.3 and matrix.

I would like the view count to display under the photos when I am logged in as admin, but not be displayed to visitors.

I found a lot of posts asking how to remove the views, but not how to remove them for visitors and leave them for admin.

How can this be accomplished?

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Sat, 2009-09-12 16:46

There's some examples here:
http://codex.gallery2.org/Gallery2:Themes:Reference:Variables

{if $user.isAdmin}
SHOW YOUR STUFF
{/if}
__________
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
BillWill

Joined: 2008-08-28
Posts: 55
Posted: Sat, 2009-09-12 22:05

Hello

I tried your example

{if $user.isAdmin}
showViewCount=true
{/if}

Didn't work.

Tried mimicking the example on the page you linked to

{if $user.isAdmin}
showViewCount=true
{else}
showViewCount=false
{/if}

That didn't work either. Both times the result was blank pages, even when I tured on debug mode, so I have no errors to report.

What am I missing here?

Thanks,
bw

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Sat, 2009-09-12 22:59

Try something like:

{if $user.isAdmin}
  {g->block type="core.ItemInfo"
            item=$child
            showDate=true
            showOwner=$showOwner
            showSize=true
            showViewCount=true
            showSummaries=true
            class="giInfo"}
{else}
  {g->block type="core.ItemInfo"
            item=$child
            showDate=true
            showOwner=$showOwner
            showSize=true
            showViewCount=false
            showSummaries=true
            class="giInfo"}
{/if}

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
BillWill

Joined: 2008-08-28
Posts: 55
Posted: Sun, 2009-09-13 10:16

I tried exactly what you posted, and it works great!

Thanks for coming back to see this through.

bw

 
manderly

Joined: 2008-04-04
Posts: 69
Posted: Mon, 2009-09-21 15:17

Hi,

I'd like to do the same thing regarding the view count. What module did you place this code in and where exactly in the module did you place it?

Sorry, I'm not very proficient in writing code...

many thanks,
manderly

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Mon, 2009-09-21 15:43

No module. album.tpl of your theme's template files:

http://codex.gallery2.org/Gallery2:Editing_Templates
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
manderly

Joined: 2008-04-04
Posts: 69
Posted: Mon, 2009-09-21 16:02

Thanks! Where do I put the code in album.tpl?

manderly

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Mon, 2009-09-21 16:09

Open the file and take a look.

You'll see a block that looks like this:

  {g->block type="core.ItemInfo"
            item=$child
            showDate=true
            showOwner=$showOwner
            showSize=true
            showViewCount=true
            showSummaries=true
            class="giInfo"}

Replace that with what is posted above.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
manderly

Joined: 2008-04-04
Posts: 69
Posted: Mon, 2009-09-21 17:48

It worked! Thank you so much!

manderly