Dynamic creation of a folder

Author Message

Marat M.

Tuesday 31 May 2005 9:03:35 am

Hi,

The site I create now is not very difficult. Almost 90% of all the necessary work is template programming which is rather simple. But the remaining 10% of functionality are far beyond my knowledge and I hope someone will help me with.

First, I have established a simple shop and customized the product class the way I want it.
Now I need two main things that, as I'm convinced, can be implemented in eZpublish:

1. I have a folder in my content tree. Let's name it 'Purchased'. I want a subfolder automatically created each time a new user is registered. The name of a sub-folder will be the same as username.
For instance, I have three users (and their usernames) recently registered with my system - User1, User2, User3. So, the tree should look like:


 Purchased (folder)
   |
   |- User1 (folder)
   |- User2 (folder)
   |- User3 (folder)

I anticipate that I should use a workflow 'content-publish-after'. But I have really no clue on how to do it. I cannot trace in documentation some more detailed explanation on using the workflows, extensions and related stuff.

2. When a user clicks 'Confirm purchase' (or, 'Checkout', no matter) the chosen products (included in the order) are moved to his personal folder (with his username) and await approval by administrator. Since then these products are NO LONGER SHOWN in the public shop. When they are approved they will be published in the user's personal folder (Purchased/[Username]).

I guess I should use some function to move content from one location (node) to another. But what function and how to use? I wish I could find a few pages of documentation that fit my case.

I do not ask for a ready code :) But if someone could show me the way where I can find additional information I would greatly appreciate it.

Thanks,
-Marat

Clemens T

Thursday 02 June 2005 2:34:58 am

I'm not sure if this is what you want, but take a look here:
http://www.ez.no/community/contribs/hacks/object_creator
Greets,
Clemens

Marat M.

Thursday 02 June 2005 4:45:47 am

Thanks, Clemens,

I reviewed that page but it is simply takes off the standard EZPublish functionality as for the creation of objects pushing submit button. As for me - I would like to implement object creation behind the scenes, so that the only button the user has to push would be the "Register" button.

However, in the extension description I found the following paragraph:

You can include it directly and create objects
with a one line function call. See 
"ObjectCreator/modules/ObjectCreator/ezobjectcreator.php".

And what does he mean by one line function call?

Thanks,
Marat

Marat M.

Sunday 05 June 2005 3:44:52 am

Ok. I see that I should create two workflows:

1. Will create a folder behind the scenes after the user logon.

2. Will move the product from the 'Shop' folder to 'Purchased/[Username]' folder after the checkout.

Am I right thinking of an event as a piece of PHP code that is created as an extension? So when you set up a workflow and a trigger function, the latter is simply executes this piece of code?

Another question - what is the connection between template code and extension code (PHP code)? Well, if I want to send some parameters from template code to the extension how can I do that?

Best regards,
-Marat

Xavier Dutoit

Sunday 05 June 2005 4:17:46 am

Hi,

Well, create the folder when the user is created (content creation, multiplexed by the class type user), not each time he/she logs on ;)

Yes, that basically a php file. Have a look there http://www.ez.no/ez_publish/documentation/development/extensions/workflow_events/creating_a_new_event

and go to the contrib area to grab one of the few existing ones as an inspiration.

What's the parameter you want to share between the template and the extension ? don't get your question.
X+

http://www.sydesy.com

Marat M.

Sunday 05 June 2005 6:21:40 am

I tried to understand something from this thread:

http://www.ez.no/community/forum/developer/how_can_we_create_content_objects_from_code

But I'm afraid I don't understand too much from the code. It seems that the code is a mix of standard PHP and some special eZpublish functions. I think I have to hire some ez programmer to do the task. A couple of hours will be enough to complete this for a person with a good knowledge of ezpublish.

Once more:

1. I need a folder to be created each time a new user is registered in the system. That folder will be his 'personal' folder with the name just like the user's username.
2. I need to have the products in the basket moved from the 'Shop' folder and published in the current (logged in) user's folder.

Maybe I have to uncover the structure of my site a bit to make my posts more understandable. It's pretty simple. :)
This is a simple shop of informational products. There is only one type (class) of product. It has 20 attributes. But only two of them - title and short_description are shown to the public in the shop. Once a buyer buys products each one is shown in his personal area on the site along with the rest 18 attributes. What is important - after a product is bought it is removed from the public area, i.e. it is unique (can be bought only once by someone).

It is obvious that it's much more easier to grab and show the contents of user's personal folder in his personal area than to separate 'bought' and 'still on sale' products in some other way. That is why I need a new folder created when a new user signs up.

So, how are the products brought into the personal folder? When a buyer clicks 'Checkout' the chosen product/products are removed from the 'Shop' (public) folder and published in his own Purchased/[Username] folder.

And the last step. You might wonder - how can I show the product to a buyer immediately after checkout when there is no payment has been made yet. The answer is - the products will be placed in his folder upon the approval by the administrator. Each time a buyer clicks 'Checkout' the chosen products are removed from the public shop and appear in the administration collaboration area where I can approve them. After the approval, the buyer can safely review them.

As for template progamming - fetching and showing the contents - I can do all that myself. I need only the core - making the work that is related to PHP and establishing workflow events.

Let me know, if you have more questions, and thanks for your help.

Best,
-Marat

Marat M.

Monday 06 June 2005 1:24:11 am

Can anyone help me with this? I agree to pay a certain sum.

-Marat

Xavier Dutoit

Tuesday 07 June 2005 1:25:45 am

Hi,

Don't know if it's inline with the rules of the forum to offer work or services on this forum.

Anyway, the problem you still have to solve is how to take the "product" node out of the catelog, "hide" it somewhere not visible from the buyer until an admin approve the order.

The approval mechanism won't be enough, but they are solutions to deal with that (using another section for that comes to my mind, but they are probably others).

I'd suggest to contact ez to see for the bespoke dev, otherwise if you're willing to release these events with a GPL licence, you can contact me ez {AT} sydesy {DOT} com

X+

http://www.sydesy.com

Marat M.

Wednesday 08 June 2005 6:57:12 am

Hi, Xavier,

I sent you a letter. Have you received it?

-Marat

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

Main resources:

Total runtime1.0226 sec
Peak memory usage4,096.0000 KB
Database Queries77

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 587.9141152.6250
Module start 'layout' 0.00520.0025 740.539139.4453
Module start 'content' 0.00771.0133 779.9844669.6250
Module end 'content' 1.02090.0016 1,449.609424.1641
Script end 1.0226  1,473.7734 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3170160.0002
Check MTime0.00130.1287160.0001
Mysql Total
Database connection0.00090.090410.0009
Mysqli_queries0.922190.1662770.0120
Looping result0.00090.0843750.0000
Template Total0.987596.620.4937
Template load0.00200.194220.0010
Template processing0.985596.365820.4927
Template load and register function0.00020.022410.0002
states
state_id_array0.00140.136210.0014
state_identifier_array0.00170.164620.0008
Override
Cache load0.00180.1801820.0000
Sytem overhead
Fetch class attribute can translate value0.00090.085330.0003
Fetch class attribute name0.00160.1526110.0001
XML
Image XML parsing0.01181.157730.0039
class_abstraction
Instantiating content class attribute0.00000.0037170.0000
General
dbfile0.01141.1156220.0005
String conversion0.00000.000740.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
8content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
20content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
10content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/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: 51
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs