Handling users with templates.

Author Message

Paul Forsyth

Thursday 30 January 2003 3:27:32 pm

Hi,

Im progressing with ez and am looking at adding users where each user will have
custom content that they can create/edit. Im having trouble finding the information I
need to allow users to handled correctly within the ez template language. I've seen
examples on sdk.ez for handling such things within the kernel but i haven't made
the connection yet with how to handle this within templates.

I can get a user to log in but what object and attributes do i access within templates
in order to determine that particular user has logged in so that i can insert a switch
statement to serve content? In addition how can i add this user information to the fetch statement
to return content belonging to that user? Are there code examples to illustrate this?

I can say more here but I want to start simple and understand the basics :)

Many thanks

Paul

Jan Borsodi

Friday 31 January 2003 3:10:29 am

> Hi,
>
> Im progressing with ez and am looking at adding users where
> each user will have
> custom content that they can create/edit. Im having trouble
> finding the information I
> need to allow users to handled correctly within the ez
> template language. I've seen
> examples on sdk.ez for handling such things within the
> kernel but i haven't made
> the connection yet with how to handle this within
> templates.
>
> I can get a user to log in but what object and attributes do
> i access within templates
> in order to determine that particular user has logged in so
> that i can insert a switch

The current user is availabe trough the $current_user variable, however this is not available from module views since modules run before the pagelayout.

> statement to serve content? In addition how can i add this
> user information to the fetch statement
> to return content belonging to that user? Are there code
> examples to illustrate this?

At the moment you cannot restrict lists by user created content, we'll consider adding this for the RC2 or the final release.

> I can say more here but I want to start simple and
> understand the basics :)

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Stuart Fenton

Friday 31 January 2003 4:45:26 am

> > Hi,
> >
> > Im progressing with ez and am looking at adding users
> where
> > each user will have
> > custom content that they can create/edit. Im having
> trouble
> > finding the information I
> > need to allow users to handled correctly within the ez
> > template language. I've seen
> > examples on sdk.ez for handling such things within the
> > kernel but i haven't made
> > the connection yet with how to handle this within
> > templates.
> >
> > I can get a user to log in but what object and attributes
> do
> > i access within templates
> > in order to determine that particular user has logged in
> so
> > that i can insert a switch
>
> The current user is availabe trough the $current_user
> variable, however this is not available from module views
> since modules run before the pagelayout.
>
> > statement to serve content? In addition how can i add
> this
> > user information to the fetch statement
> > to return content belonging to that user? Are there code
> > examples to illustrate this?
>
> At the moment you cannot restrict lists by user created
> content, we'll consider adding this for the RC2 or the final
> release.
>
> > I can say more here but I want to start simple and
> > understand the basics :)

I need to be able to have custom content per user as well where only the specific user can edit their own information. Since the user account is edited only by the user in question can I use the user account as the link to their own content by related object.

This way I can get a workaround while waiting for this feature as it is essential to the whole operation of my site.

If not when will this functionality be available?

Is it possible to simply limit access to these layouts by putting them into a section and defining a role allowing only users from a specific group to access them then display the details using the $current_user variable?

Thanks in advance.

Paul Forsyth

Friday 31 January 2003 6:11:05 am

> > Hi,
> >
> > Im progressing with ez and am looking at adding users
> where
> > each user will have
> > custom content that they can create/edit. Im having
> trouble
> > finding the information I
> > need to allow users to handled correctly within the ez
> > template language. I've seen
> > examples on sdk.ez for handling such things within the
> > kernel but i haven't made
> > the connection yet with how to handle this within
> > templates.
> >
> > I can get a user to log in but what object and attributes
> do
> > i access within templates
> > in order to determine that particular user has logged in
> so
> > that i can insert a switch
>
> The current user is availabe trough the $current_user
> variable, however this is not available from module views
> since modules run before the pagelayout.

Im a little confused about whether this is a yes, i can performed a switch based on $current_user, or not. I've heard that rc2 will contain more documenation and examples about users. Would it be possible to provide a little sample code for this? Performing a grep on the source code does show $current_user being used in a few places but its not enough to illustrate how to use for my purpose.

Stuart wrote:
"Is it possible to simply limit access to these layouts by putting them into a section and defining a role allowing only users from a specific group to access them then display the details using the $current_user variable?"

I have something similar like at the moment. All users+anonymous can view the information, but only my users can edit/create. However, for example, i would love to have a little area thats lists information that *only* the logged in user has created/edited. My current level of knowledge leads me to believe a fetch with user information would be required. Is there another way?

Thanks

Paul

Paul Forsyth

Friday 31 January 2003 6:11:21 am

> > I can get a user to log in but what object and attributes
> do
> > i access within templates
> > in order to determine that particular user has logged in
> so
> > that i can insert a switch
>
> The current user is availabe trough the $current_user
> variable, however this is not available from module views
> since modules run before the pagelayout.

Im a little confused about whether this is a yes - can i perform a switch based on $current_user - or not. I've heard that rc2 will contain more documenation and examples about users. Would it be possible to provide a little sample code for this? Performing a grep on the source code does show $current_user being used in a few places but its not enough to illustrate how to use for my purpose.

Stuart wrote:
"Is it possible to simply limit access to these layouts by putting them into a section and defining a role allowing only users from a specific group to access them then display the details using the $current_user variable?"

I have something similar like that at the moment. All users+anonymous can view the information, but only my users can edit/create. However, for example, i would love to have a little area thats lists information that *only* the logged in user has created/edited. My current level of knowledge leads me to believe a fetch with user information would be required. Is there another way?

Thanks

Paul

Paul Forsyth

Friday 31 January 2003 6:13:03 am

> > I can get a user to log in but what object and attributes
> do
> > i access within templates
> > in order to determine that particular user has logged in
> so
> > that i can insert a switch
>
> The current user is availabe trough the $current_user
> variable, however this is not available from module views
> since modules run before the pagelayout.

Im a little confused about whether this is a yes - can i perform a switch based on $current_user - or not. I've heard that rc2 will contain more documenation and examples about users. Would it be possible to provide a little sample code for this? Performing a grep on the source code does show $current_user being used in a few places but its not enough to illustrate how to use for my purpose.

Stuart wrote:
"Is it possible to simply limit access to these layouts by putting them into a section and defining a role allowing only users from a specific group to access them then display the details using the $current_user variable?"

I have something similar like that at the moment. All users+anonymous can view the information, but only my users can edit/create. However, for example, i would love to have a little area thats lists information that *only* the logged in user has created/edited. My current level of knowledge leads me to believe a fetch with user information would be required. Is there another way?

Thanks

Paul

Rib Rdb

Tuesday 04 February 2003 2:21:10 pm

it is possible to add the variables $current_user and $anonymous_user_id to a content view template by searching for
$tpl->setVariable( 'node', $node ) in kernel/content/view.php
and placing these two lines before it.
$tpl->setVariable( "current_user", $user );
$tpl->setVariable( "anonymous_user_id", $ini->variable( 'UserSettings', 'AnonymousUserID' ) );

> > > Hi,
> > >
> > > Im progressing with ez and am looking at adding users
> > where
> > > each user will have
> > > custom content that they can create/edit. Im having
> > trouble
> > > finding the information I
> > > need to allow users to handled correctly within the ez
> > > template language. I've seen
> > > examples on sdk.ez for handling such things within the
> > > kernel but i haven't made
> > > the connection yet with how to handle this within
> > > templates.
> > >
> > > I can get a user to log in but what object and
> attributes
> > do
> > > i access within templates
> > > in order to determine that particular user has logged
> in
> > so
> > > that i can insert a switch
> >
> > The current user is availabe trough the $current_user
> > variable, however this is not available from module
> views
> > since modules run before the pagelayout.
> >
> > > statement to serve content? In addition how can i add
> > this
> > > user information to the fetch statement
> > > to return content belonging to that user? Are there
> code
> > > examples to illustrate this?
> >
> > At the moment you cannot restrict lists by user created
> > content, we'll consider adding this for the RC2 or the
> final
> > release.
> >
> > > I can say more here but I want to start simple and
> > > understand the basics :)
>
> I need to be able to have custom content per user as well
> where only the specific user can edit their own information.
> Since the user account is edited only by the user in
> question can I use the user account as the link to their own
> content by related object.
>
> This way I can get a workaround while waiting for this
> feature as it is essential to the whole operation of my
> site.
>
> If not when will this functionality be available?
>
> Is it possible to simply limit access to these layouts by
> putting them into a section and defining a role allowing
> only users from a specific group to access them then display
> the details using the $current_user variable?
>
> Thanks in advance.

Jan Borsodi

Wednesday 05 February 2003 4:04:06 am

> I need to be able to have custom content per user as well
> where only the specific user can edit their own information.
> Since the user account is edited only by the user in
> question can I use the user account as the link to their own
> content by related object.
>
> This way I can get a workaround while waiting for this
> feature as it is essential to the whole operation of my
> site.
>
> If not when will this functionality be available?
>
> Is it possible to simply limit access to these layouts by
> putting them into a section and defining a role allowing
> only users from a specific group to access them then display
> the details using the $current_user variable?

A fetch function has been added for the user module, this means that the current user can be fetched with.
{fetch('user','current_user')}

For instance do
{fetch('user','current_user')|attribute(show,1)}
to get the attributes.

This new function will be present in RC2.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.