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.

eZ debug

Timing: Jan 18 2025 22:23:29
Script start
Timing: Jan 18 2025 22:23:29
Module start 'layout'
Timing: Jan 18 2025 22:23:29
Module start 'content'
Timing: Jan 18 2025 22:23:29
Module end 'content'
Timing: Jan 18 2025 22:23:29
Script end

Main resources:

Total runtime0.8202 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 589.3359152.6250
Module start 'layout' 0.00540.0046 741.960939.4453
Module start 'content' 0.01000.8086 781.4063580.0391
Module end 'content' 0.81860.0016 1,361.445316.1641
Script end 0.8202  1,377.6094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.4481160.0002
Check MTime0.00150.1879160.0001
Mysql Total
Database connection0.00070.088710.0007
Mysqli_queries0.751491.6052630.0119
Looping result0.00070.0844610.0000
Template Total0.779295.020.3896
Template load0.00250.298820.0012
Template processing0.776794.699120.3884
Template load and register function0.00010.014010.0001
states
state_id_array0.00100.120710.0010
state_identifier_array0.00150.185520.0008
Override
Cache load0.00220.2638550.0000
Sytem overhead
Fetch class attribute can translate value0.00070.089220.0004
Fetch class attribute name0.00130.161660.0002
XML
Image XML parsing0.00070.080320.0003
class_abstraction
Instantiating content class attribute0.00000.002480.0000
General
dbfile0.00080.0991180.0000
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 35
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs