I only want to display custom fields to logged in users.. others that are guests, that are not logged in.. will not see the custom filelds... how can this done on the template level?
like
{if userloggedin}
<h2 class="giTitle">Custom Field</h2>
{/if}
I hope i am making myself somewhat understandable..
any help that can be given to me will be greatly appreciated...
Posts: 8601
we don't yet have a standard flag for logged-in or not, but for now you can change this in layouts/matrix/templates/albumBody.tpl and singleBody.tpl
to
Posts: 32509
i guess this is a fairly popular request (having something like {g->isRegisteredUser}, or {g->isAdmin} don't you think?
Posts: 8601
it needs to be something that can be used in {if} so maybe just standardize a template variable, like $user.isRegisteredUser or $user.isLoggedIn, and $user.isAdmin
Posts: 35
maybe we could create a module for this instead... at least for now.. i wouldnt really like to start changing source code around to get this to work more effiently on the template level.. and since we are in BETA.. i would like the files to be intact at least intill final release.. perhaps just writing out a function that we could call on any template page a member function where maybe we could get the users info like either they are logged in or not amongst other things.. would add more dynamic flare to this... we could force certain themes to be used by certain groups..
I really have not looked at the DB structure yet to see if this stuff is actually stored there or not.... or is it stored in flat file somehwere? I know G1 was totally flatfile.. so i really do not know how much G2 really leaned on the DB..
What I am also trying to do is.. instead of showing custom fields to logged in users.. i also only wanting to show the
$layout.item.description
description field as well.... I can see from the example above you are just looking at the url to know to show the custom field or not.. or am i wrong?
please help... thanks alot in advance
Posts: 8601
the url is not involved.. it is looking at the data used to build the page.
the changes i suggested above would be a local template and no code change is required.
Posts: 35
Posts: 8601
can't you apply the same technique?
Posts: 35
I guess if i really could understand the variable scope being used in these templates.. i wouldnt be asking these lame questions...
it seems to me that the above example checks to see if the custom field module is being used and then making sure the user is logged in.. then if both are true.. then the custom fields are shown... but can i really use the same technique for the description?
please excuse my stupidity...
Posts: 35
so i went ahead and tried to do the first example.. it shows the custom field regardless if i am logged in or not..
hmmmm.....
if i cant get this to work.. then i cant really build on the original example to get the description to work the way that I want it to...
I am trying to get the desciption to only show if the user is logged in....
Posts: 8601
itemDetailFiles are additional content added by modules.. comments, custom fields, exif all use item detail content to display stuff below the album/image.
description isn't part of the itemDetailFiles loop.. look elsewhere in the tpl for where description is displayed.. you can put {if $layout.user.id!=4} .... {/if} around anything you want only shown to logged in users.
Posts: 35
ok.. will do.. i will try this right away mindless... i really appreciate your tireless effort here..
Posts: 35
ok.. using the below example has no effect on showing description info to user logged in or not..
what gives?
Posts: 8601
just above that {if put this:
{$layout.user.id}
this should put the id of the current user someone on the page.. see what value it has when you're logged in and not logged in.. we're expecting it to be 4 when you're not logged in.
Posts: 35
ok... {$layout.user.id} does in fact equal 4... but still.... no luck...
admin equals 5
but for some strange reason we cant use the {if} conditional to choose wether or not to display the information field.. or really.. anything for that matter... becasue it doesnt work for custom field either...
Maybe It would help to say that I only have two users..
admin
and
guest
I also have only 3 groups.. and those are
All Users
Everybody
Site Admins
I also would like to know what is in the $layout[user] array.. would group id be in there.. it would be much easier to do than member id...
Posts: 35
wow.. works a charm... i really feel like a dumb ace becasue i was working with thw wrong instance of where the description is called..
everything is working just fine.. I am so terribly sorry for my mistake.. and really would like to thank you for the time and help mindless...
Posts: 8601
:D
Posts: 8601
I have made a standard template variable so user info is available to every view. You can reference these in any tpl: $user.userName, $user.fullName, $user.isGuest, $user.isRegisteredUser, $user.isAdmin
Update from cvs in a few hours or get tomorrow's nightly snapshot to try this out. If you have any references to $layout.user in your local tpl files you'll need to change these to just $user.