Jump to content

Looking for some suggestions / help


Hari KT
 Share

Recommended Posts

Hi Guys,

I am looking for the best way what you feel when doing this. Basically the idea is to save the history of a user.

Consider we have a bunch of products, and categories. And the user needs a way to save a product and check it for later use. Consider the same as you follow a topic in the PW forum.

I was thinking to add a page which have 2 fields

1 ) user_id which is of type Page which is linked to the user template of PW 

2 ) product_id which is also a Page which I have built from another template

I have removed the global title, but it needs the url always entered.

$page = new Page();
$page->template = 'product-history-user';
$page->parent_id = 'parent-id';
$page->name = 'something';
$page->history_user_id = $user->id;
$page->user_history_product_id = 'id-of-product';
$page->save();

I also have some more stuffs that needs similar logic. Interested to hear your thoughts to make this better.

Update :

One more problem I missed to write is, I need to sort it based on the priority, that is why I opted the way.

or is there a way we can store the date and time of the product when saved?

Thanks

Edited by Hari KT
Link to comment
Share on other sites

ok. So I will move with adding Page field in user template.

Sorry I missed to write one more problem, I need to sort it based on the priority ?

and also store the date and time of the product when saved.

Thank you cstevensjr, Martijn Geerts

  • Like 2
Link to comment
Share on other sites

Hi Soma,  Martjin,

Let me make the question more clear with the examples you mentioned.

We have Categories->Products ( x1, x2, x3, x4, x5, x6 )

Let us assume the user saves products in the order x4, x1 .

Now in the user template we have a field with user_product which is multi page array whose template is product. So when the user save the first one we need to track the time when the product is added.

$user->user_product->add($product1); // May be id or page object

// Now we need to know when the product1 is added

That means we need an extra field for the user to know at what time the product is saved, else we will not be able to keep track of the order in which the user has saved.

Link to comment
Share on other sites

Then I would create a new template "user-order" add a single page field "product" and a datetime field to the template. Then create a new order with this template , and save it under the user page. I think you just need to allow children on the family settings on the user template.

Link to comment
Share on other sites

Thanks @Soma, that was what I ended up and then the first question comes, "I have removed the global title, but it needs the url always entered.".

Seems like I want to set a datetime string format for the url.

Thank you for all the support every one have showed. Marking as solved.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...