User's Objects on Profile

Author Message

kracker (the)

Friday 22 April 2005 12:01:42 pm

Hey Joanie,

Fyi this is a side step reply to Joanie Chembars'
http://ez.no/community/forum/general/3_4_4_showing_user_posted_article_links_on_profile_page
But the forums won't let anyone reply to it because of a forum thread reply template subject length bug (ez crew ...)

I too saw Paul's contribution today and though it would be fun to test drive it ;)

What I'd to use it was override the default design/standard/user/edit.tpl to include the following:

<div style="font-weight:bold;">My Posts</div>

{default current_user_id=$userAccount.contentobject_id
     my-limit=25
     mine=fetch(content,tree,hash(parent_node_id,2, attribute_filter, array(and,array('owner','=',$current_user_id ) ) ) )
     my-count=$mine|count()
}

<b>Total:</b> {$my-count}

  {section show=$my-count|gt(0)}
    <ul>
      {section var=it loop=$mine}
        <li><a href={$it.url_alias|ezroot}>{$it.name}</a></li>
      {/section}
     <ul>
  {/section}

The trick is how many objects do you want to show. I have over a hundred on my installation so I put a lmit in in the code like so ...

<div style="font-weight:bold;">My Posts</div>

{default current_user_id=$userAccount.contentobject_id
     my-limit=25
     mine=fetch(content,tree,hash(parent_node_id,2, limit,$my-limit, attribute_filter, array(and,array('owner','=',$current_u\
ser_id ) ) ) )
     mine-total=fetch(content,tree,hash(parent_node_id,2, attribute_filter, array(and,array('owner','=',$current_user_id ) ) \
) )
     my-count=$mine-total|count()
}

<b>Total:</b> {$my-count}

  {section show=$my-count|gt(0)}
    <ul>
      {section var=it loop=$mine}
        <li><a href={$it.url_alias|ezroot}>{$it.name}</a></li>
      {/section}
     <ul>
  {/section}

There are still lots more ways to better use this functionality. This is just a simple example that worked for me.

Might want to brush up on the documentation at the same time, tho :)

References:
http://ez.no/community/forum/setup_design/letting_users_edit_their_profile
http://ez.no/community/contribs/hacks/more_attribute_filter_operators_and_fetch_by_owner_id
http://ez.no/ez_publish/documentation/reference/data_fetching/content/tree

Cheers,
//kracker

311 : Seems Uncertain (String Quartet Mix)

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

kracker (the)

Friday 22 April 2005 12:29:24 pm

And it's worth pointing out here that user_statistics is also a popular extension which can also be used on the user's profile:

http://ez.no/community/contribs/template_plugins/user_statistics

cheers,
//kracker

salvia : your disease

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Joanie Chembars

Thursday 05 May 2005 3:42:06 am

Kracker -
Thanks so much for the links and sample code. I hope to try this today if I can find some spare time..........
Joanie

Joanie Chembars

Friday 06 May 2005 5:18:02 am

Hey -
Code works great with one edit........

this line

<li><a href={$it.url_alias|ezroot}>{$it.name}</a></li>

should say ezurl and not ezroot

Joanie

kracker (the)

Friday 06 May 2005 5:24:11 am

Joanie,

While <i>ezurl</i> may be the correct choice for your situation.

Others who have configured eZ publish urls to omit the /index.php/designname/ from urls generated by eZ publish. Instead they would use <i>ezroot</i>

Here is an example of a nice url using <i>ezroot</i>

http://example.org/news/fsf/jobs

It is often common when a site is in initial development to use the default configuration which includes the index.php and siteaccess in the urls eZ publish generates.

This is because you can setup and start using eZ publish in a non-virtual host environment. This can make getting a default eZ publish installation running, configured and branded very quickly without a lot of web server configuration.

Yet when moving the site from development to production it is a widely known and accepted fact that your web site users will benefit greatly from you switching from using ezurl to ezroot in your design/ templates.

This is because it makes urls and bookmarks simpler to read, understand, remember, advertise, type from memory, use, look at,etc.

I guess it's what I would call one of my favorite, <b>eZ publish Best Practices</b>

Cheers,
//kracker

Dark City : (Hughes Hall) : Sleep Now

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

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