Fetching and listing Clients

Author Message

Softriva .com

Monday 28 August 2006 1:16:39 am

I have made a class called clients. It has an attribute called client_type where I can put “IT”, “Fashion”, “Education”, etc based on the actual business of my clients. Now, I need to list these clients as

Fashion
1.Client 1
2.Client 2
3.and so on.....

Education

1.Client 1
2.Client 2
3.and so on.....

I started with:

{def $srClients=fetch('content', 'list', hash('parent_node_id','62', 'sort_by',array('priority',false())))} 

Can you help?

Claudia Kosny

Wednesday 30 August 2006 2:41:01 pm

Hi OOzy

I had a similar problem earlier on and could not find a really good solution. But there are the ideas I came up with:

1)Fetch all nodes sorting them both by client_type and name(or whatever you secondary sort option is). So the sort parameter would look somehow like this:
'sort_by', array( array( 'attribute', true(), 'clients/client_type ),
array( 'name', true())

Then you just need to display a heading each time the client_type changes and start your numbering of the listed clients again.
Advantage: easy to do
Disadvantage:
- does not work if you need custom sorting of the client_type,
- is problematic if you don't want to iterate though the entire array all at once

2) Fetch all nodes, push them in a multidimensional array which has the client_type as first key, e.g
$arr[$client_type][]=$node1
$arr[$client_type][]=$node2

Sort the array according to the order of your listing of the client types and iterate through it to display your nodes.
Problem: If you have lots of nodes, this will slow you system down considerably. This can be partially alleviated by not not storing the entire node but just the necessary data (often only the name and the url_alias). Still, this is suitable only for rather small sites.

3) Change the type of the client_type attribute to product category.
Advantage: You can fetch the product categories using a simple fetch ('shop', 'product_category_list'). Once you have the categories you can fetch the nodes for each category using an attribute filter.
Advantage: easy to do
Disadvantages:
- clients cannot have arbitrary client type, you have to add each client type to the product category before you can add the client object
- problems possible when changing or removing a client type

4) Make the client type an ezselection - which is roughly the same as 3)

5) Create a separate folder which will hold a dummy article for each client type.
Add a object relation to your client class and relate to the dummy article.
To display the listing, fetch all dummy articles and fetch the reverse_related_objects.
Advantage: still easy to do, no big problems when changing or removing a client_type
Disadvantage:
- not very intuitive
- still need to create client_type article before creating object
- no idea how much work it is for EZ to get the reverse related objects - might be slow

Greetings from Luxembourg

Claudia

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 21:15:54
Script start
Timing: Jan 18 2025 21:15:54
Module start 'layout'
Timing: Jan 18 2025 21:15:54
Module start 'content'
Timing: Jan 18 2025 21:15:54
Module end 'content'
Timing: Jan 18 2025 21:15:54
Script end

Main resources:

Total runtime0.0160 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 587.9141152.6250
Module start 'layout' 0.00570.0032 740.539139.4453
Module start 'content' 0.00890.0048 779.984489.3359
Module end 'content' 0.01370.0023 869.320334.3047
Script end 0.0160  903.6250 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002716.5742140.0002
Check MTime0.00127.2186140.0001
Mysql Total
Database connection0.00074.065910.0007
Mysqli_queries0.002515.725130.0008
Looping result0.00000.105610.0000
Template Total0.002012.410.0020
Template load0.00106.418510.0010
Template processing0.00105.982810.0010
Override
Cache load0.00063.948410.0006
General
dbfile0.00031.815880.0000
String conversion0.00000.062540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs