Skip Navigation

[Resolved] New Entry Tracking

This thread is resolved. Here is a description of the problem and solution.

Problem:

Setup a vehicles Tracking systems.

Solution:

I suggest you setup a child post type for it, for example:

https://toolset.com/forums/topic/new-entry-tracking/#post-1686143

Relevant Documentation:

https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/

This support ticket is created 4 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 20 replies, has 2 voices.

Last updated by larryL 4 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1685889

I have a CPT called 'vehicles' with numerous custom fields (garage, level, space,driver, state, tag#, etc...). In the CPT there are entries for each vehicle.

Each time the garages are checked the vehicle might be in a new space (or garage) and a new entry for the vehicle (it's tracked by VIN) would be entered.

My question(s) is:

1 - How can only show the most recent entry in 'vehicle' view of all entries for that vehicle?
2 - How can I generate a report of how many times that vehicle has been moved?
3 - How can I generate a report of how long a vehicle has been in one location, and, show it's time by color coding in the view? For example, 10 days green, 40 days, yellow, more than 90 days red?

Thanks!

Larry

#1686143

Hello,

In your case, I suggest you setup a child post type for it, for example:
- Parent post type "vehicles"
- child post type "vehicles movement"( with custom field "garages")
https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/

In a single "vehicles" post, display related "vehicles movement" posts information:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items

Q1) How can only show the most recent entry in 'vehicle' view of all entries for that vehicle?
It needs a child post view with settings: display only one item, and order by post date DESC

Q2) It needs another child post view, and output shortcode [wpv-found-count]:
hidden link

Q3) It needs custom codes, for example, you can create a custom shortcode:
https://developer.wordpress.org/reference/functions/add_shortcode/
get the latest child "vehicles movement" post(see Q1), and calculate the days between post date and current time, then display different color as what you want.

#1687259

Hi Luo,

Long time to speak!

Great idea with the alternate CPT, I wish I thought of that myself. I think I'm getting rusty. Anyway, I added that along with a function to update the title/slug from one of the custom fields. But I'm stuck on getting the parent/child relationships setup. I tried following the guides and I think I'm missing something. I did setup 1 to many relationships between Vehicles and Vehicle Movements. But when I follow the instructions for the views everything just disappears.

Can you please either point me to a better walk through that provides step by step (like click this , then that) without using confusing it with examples or lend me a hand? For some reason when I try to follow the breakthroughs on toolset that include examples (ie. say you want to build a site with rooms and beds, create the rooms and beds this and that blah blah) I can't keep the instructions straight. But the answers in support that are Black and White with bullet points and code, I'm fine.

#1688385

For the new problem:

I did setup 1 to many relationships between Vehicles and Vehicle Movements. But when I follow the instructions for the views everything just disappears.

It is abnormal, Toolset post type relationship is built-in feature of Toolset plugins, I suggest you check these:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) Make sure you are following our document to setup the relationship and display the related child posts:
https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items
There are detail steps and videos in above documents

3) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2020, deactivate all custom PHP/JS code snippets, and test again

#1689551

OK. I don't know why this is happening. I know you hear this 1000 times a day but it was working before and now it's not.

I checked the version #'s and they are the latest versions. I'm currently using Divi. I know you guys did have some issues with Divi so perhaps that is the problem? When I swith to 2017 the view shows up. When I switch back to Divi the view disappears. HOWEVER, this only impacts the view on my homepage. So I can't figure out why this is happening.

#1689563

A few other question - How do I get the child to automatically update the parent's related information section?

The examples/walkthrough are not exactly what I'm trying to do. What I need to do is, in my view,show all the parents EXCEPT when their is a child (or children), and then show the most recent child entry only in the list.

So if i have a list of cars:

Red Honda Accord Space 1
Blue Chevy Monte Carlo Space 2
Green Toyota Solara Space 10

And someone updates the info for the Blue Chevy, then that entry is replaced with the new 'post' infor for the update.

Red Honda Accord Space 1
Blue Chevy Monte Carlo Space 19
Green Toyota Solara Space 10

And so on....

Thanks!

#1689619

For the question:

When I switch back to Divi the view disappears.

How do you setup/create the view? with classic editor or blocks editor?
If it is blocks editor, you will need to setup a view with classic editor(Dashboard-> Toolset-> Views), and test again, Toolset Blocks plugin is based on WordPress blocks editor, blocks editor and DIVI builder are both page builders, it is not recommended to design same page/post with two page builder, it will conducts unexpected result.

For other new questions, please check the new thread here:
https://toolset.com/forums/topic/how-do-i-get-the-child-to-automatically-update-the-parents-related-information-section/

#1690345

No, I use classic editor. Blocks editor makes my brain hurt.

#1690351

Also, I don't think they were new questions. I was really just clarifying the original question. You sent me walkthroughs for relationships but they don't do what I'm trying to do.

#1690855

The problem you mentioned is abnormal, please check these:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) In case it is a compatibility problem, please deactivate all other plugins, and switch to original DIVI theme, and test again

3) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/

4) If the problem still persists, please provide a copy of your website, you can put the package files in your own google drive disk, share the link only, also point out the problem page URL and view URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1691843

I've resolved the display issue.

Let's return to the original question if we could. Thanks!

#1692443

There are lots of questions in this thread, which one is the original question?
Is it this?
https://toolset.com/forums/topic/new-entry-tracking/#post-1689563

If it is, as I mentioned previously, the problem is abnormal:

when you add an item in relationship section, it should have an entry for the parent, please check the same steps as I mentioned in previous thread:

https://toolset.com/forums/topic/new-entry-tracking/#post-1690855

Private message box enabled again.

#1693239

My question(s) is:

1 - How can only show the most recent entry in 'vehicle' view of all entries for that vehicle?

Your examples did not match what I'm trying to do. The originally entry in the CPT (vehicles) will be superceeded by one (or more ) entries in the new CPT (vehicle movements). I need to replace the original 'vehicle' entry in the view with the LAST entry (if there is one) in the 'vehicle movements' CPT based upon the 'vin' field.

Then:
2 - How can I generate a report of how many times that vehicle has been moved?
I'm assuming I can just use [wpv-items-count] to do this? But I'm not clear on the filtering if I even need to do any?

3 - How can I generate a report of how long a vehicle has been in one location, and, show it's time by color coding in the view? For example, 10 days green, 40 days, yellow, more than 90 days red?

I might be over complicating this. How do I show how many days since the post was entered?

In terms of the conditionals, I've tried to make sense of the walkthroughs and I think I'm missing something. If I want to apply those rules (ie: <= 10days color=green, etc..) how would I do that all to the same field?

#1697649

I think there are lots of misunderstandings.

In your case, if you replace/update 'vehicle' post with new values, its old values will lost, you can not get it's old values any more, so you will not achieve rest requests 2) and 3).

So as I suggested above, it needs a child post type , for example "vehicles movement", setup one-to-many relationship between post type 'vehicle' and "vehicles movement", so you will get and manage the history of "vehicles movement" of a specific 'vehicle' post easily.

I suggest you check the steps and documents I mentioned above:
https://toolset.com/forums/topic/new-entry-tracking/#post-1686143

If you still need assistance for it, please provide a test site with the same problem, I can setup a demo for you.

#1704869

Thanks for the details, I have done below modifications in your website:
1) Edit a "vehicle" post:
hidden link

in section "vehicles vehicle movements", add and connect a "vehicle movements" posts, you can add more child posts here.

2) Create a post view "the most movement recent entry" here:
hidden link

3) Create a post view "how many times that vehicle has been moved":
hidden link

For details of above both two views, please check the my first answer above:
https://toolset.com/forums/topic/new-entry-tracking/#post-1686143

4) Edit content template:
hidden link

Display above two views:

1 - How can only show the most recent entry in 'vehicle' view of all entries for that vehicle?
{!{wpv-view name="the-most-movement-recent-entry"}!}

<hr>

2 - How can I generate a report of how many times that vehicle has been moved?
{!{wpv-view name="how-many-times-that-vehicle-has-been-moved"}!}

...

Test it in front-end:
hidden link

I can see it works fine.

For the question 3), since you did not provide FTP access, so I won't be able to setup the custom shortcode in your website, you will need to follow WP document to setup the custom shortcode:
https://developer.wordpress.org/reference/functions/add_shortcode/

To calculate the days, please check related thread:
https://stackoverflow.com/questions/2040560/finding-the-number-of-days-between-two-dates

You can follow our document to use above custom shortcode in [wpv-conditional] shortcode, check the days value, then display different text/images:
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/using-shortcodes-in-conditions/