Forums / Developer / ez Publish methodology

ez Publish methodology

Author Message

Patrick ALLAERT

Friday 12 August 2005 2:27:04 am

I would like here to discuss about some methodologies and best practicies when creating an ez Publish site with lot of business logic.

I will begin with a (general?) question about the class model.

Let me first explain the purposes of the site we are creating.

The site will be a portal to <b>several</b> companies with own products, orders, promotions, events, job infos,... All this information will have an apropriate content class (Company, Product, Order, Promo, Event, ...)

Information will be reachable in different ways sometimes with lot of business logic. ex: A page that display the list of <i>users</i> having purchased <i>products</i> of a specified <i>company</i>.

I would like to have some comments about: When to create an (enhanced?) objectrelation attribute and when to create a child object using nodes ?

In my opinion, it should be much easier to create a logic in the placement of nodes than a template that will do a lot of complicated fetches !

Continuing with the example above, it is probably easier to have this structure:

-- Company One
 +-- Buyers
   +-- Person One
-- Company Two
 +-- Buyers
   +-- Person One
   +-- Person Three
-- Company Three
 +-- Buyers
   +-- Person Two
   +-- Person Three

And the day the <i>Person Two</i> buy a product of <i>Company One</i> an additional node on <i>Person Two</i> is created under <i>Company One/Buyers</i>.

This may be probably implemented by a workflow.

Now add some "categories of products" with the class <i>Category</i> that is general for all companies. How do I manage the relation between a category, a product, a buyer,... ?

What about displaying all products under a specific category ? Or all products of a company in a specific category ?

What about displaying all products (of every companies) that have been bought on the portal.

Following my opinion, will I have to create as much directories structure and workflows as "views" ?

In a OO model I will have some functions like:

Company {

Persons[] getBuyers() {
...
}

Persons[] getProductBuyers(Product p) {
...
}

}

What is your methodology to create such behaviors ?

Thanks for your help :)

Patrick ALLAERT
http://www.dixite.com/
http://users.pandora.be/patrick_allaert/

Paul Borgermans

Friday 12 August 2005 10:14:46 am

Patrick

You are right about implementing the logic mainly with the node placements, although object relations may be well suited for your categories. In your explanation, you seem to indicate "forward" and "reverse" relations. If that's the case, related objects are the best way to proceed.

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Patrick ALLAERT

Tuesday 16 August 2005 7:51:55 am

Thanks for your suggestion Paul, I think object relation is effectively the right way to implement direct relation between two objects or when the <i>logic</i> is simple. But in my case (we have more than 60 classes) it is really time consuming to do so...

An order is <b>related</b> to a <i>customer</i> and made of several <i>order_detail</i>'s.
An <i>order_detail</i> is related to a <i>product</i>.
The <i>product</i> is under an object of type <i>company</i>.
And I am under a specific <i>company</i> (only one) because I am a responsible of it.

What I need to do here is: <b>Give me the list of persons that have bought something of my company!</b>

With standards <i>object relations</i> and parent/child relations I have to do this:

1. Retrieve the <i>company</i> (<b>C</b>) I belong to.
2. Retrieve the <i>products</i> (<b>P</b>) of <b>C</b>.
3. Retrieve the <i>order details</i> (<b>OD</b>) having a link with <b>P</b>'s.
4. Retrieve the <i>orders</i> (<b>O</b>) the <b>OD</b>'s belong to.
5. Retrieve the <i>persons</i> (buyer: <b>B</b>) linked with <b>O</b>'s.
6. <b>B</b> is the list I want...

In case I want some stats on <i>orders</i> I will have to repeat step 1 to 4.

In a OO language, I will have a strong <b>class model</b> and several methods like
a) <i>Company::getBuyers()</i>: return a list of persons having bought something of this company.
b) <i>Company::getProducts()</i>: return the list of product of this company.
c) <i>Product::getBuyers()</i>: return a list of persons having bought this product.
d) ...

Where method a) will be built using b) and c)

Still waiting for an eZ Publish OO guru... ;)

Patrick ALLAERT
http://www.dixite.com/
http://users.pandora.be/patrick_allaert/

Gabriel Ambuehl

Tuesday 16 August 2005 9:09:16 am

Sounds like you should write something custom if you have that specific needs. You can still integrate such an extension with ezpublish of course.

(I don't know of any pre made CMS that really does what you're after, BTW).

Visit http://triligon.org

Patrick ALLAERT

Friday 19 August 2005 1:10:25 am

I don't think that creating a business logic (or API) behind classes is a <i>specific need</i>...
I think that for now they are still no <b>best practicies</b> for doing this! Of course when your are creating 3 -> 10 custom classes you may always use fetch's functions. But when you reach more than 60 classes, you just can't!

Maybe this approach may be used:
Creating a set of templates that do some <b>core business logic</b> and other templates for the presentation.

Example:

{include uri='api/company/getProducts.tpl'
         company_id=125
}
{* Looping through results *}
{section loop=$results}
  ...
{/section}

This way I don't worry if products and companies are linked with <b>object relations</b> or <b>parent/child relations</b>!

IMHO, this addresses the most disadvantage of eZ templates, business logic is far to often in the template!

Patrick ALLAERT
http://www.dixite.com/
http://users.pandora.be/patrick_allaert/

eZ debug

Timing: Jan 18 2025 15:17:14
Script start
Timing: Jan 18 2025 15:17:14
Module start 'content'
Timing: Jan 18 2025 15:17:15
Module end 'content'
Timing: Jan 18 2025 15:17:15
Script end

Main resources:

Total runtime0.8378 sec
Peak memory usage4,096.0000 KB
Database Queries202

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 589.1172180.8438
Module start 'content' 0.00580.7161 769.9609616.3828
Module end 'content' 0.72190.1159 1,386.3438341.3984
Script end 0.8378  1,727.7422 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.4842210.0002
Check MTime0.00160.1924210.0001
Mysql Total
Database connection0.00070.084610.0007
Mysqli_queries0.763591.12682020.0038
Looping result0.00200.23492000.0000
Template Total0.805796.220.4029
Template load0.00200.238720.0010
Template processing0.803795.927420.4019
Template load and register function0.00020.018410.0002
states
state_id_array0.00090.112410.0009
state_identifier_array0.00080.095820.0004
Override
Cache load0.00180.2097610.0000
Sytem overhead
Fetch class attribute can translate value0.00120.141640.0003
Fetch class attribute name0.00110.127660.0002
XML
Image XML parsing0.00090.105340.0002
class_abstraction
Instantiating content class attribute0.00000.001560.0000
General
dbfile0.00340.4064280.0001
String conversion0.00000.001130.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 28
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs