tuxy Posted March 10, 2015 Share Posted March 10, 2015 A fitnesscoach asked me to develop a great new site. It would have over more than 100 short workout video's (max 1 min/video). The coach makes a personal program for each client. In the backend the coach (=admin) selects the video's for each client. Then the client logs in and he only can see the video's that are selected for him. Examples: - Client x -- video 4 -- video 67 -- video 78 --.. Client y -- video 19 -- video 67 -- video 69 --.. Client z -- video 4 -- video 18 -- video 78 -- .. Can anyone give me some suggestions, tips and hints, or practical examples required realizing this project? All help is welcome, thanks already. Regards, Christophe Link to comment Share on other sites More sharing options...
ESRCH Posted March 10, 2015 Share Posted March 10, 2015 Oooooh, I love this moment when you first think about the possible structure of a website, and all the great things you can do with it, it's awesome My take on a possible structure could be: Home -- My Program (only accessible to logged in users) ---- Video 1 (video template with a video_file field to store the video) ---- Video 2 ---- Video 3 ---- ... -- About -- Contact You can create a page field called selected_videos, that links to the video template, and that you add to the user template (Setup>Templates>Filters>Show system templates) so that the coach can select the videos he suggests for each user. Then at the beginning of the video template, you can have some code like this to make sure that a user can only see the selected videos: (Edit: I made a typo, so I corrected from $user->has to $user->is) if (!$user->is("selected_videos=$page")) $session->redirect($page->parent->url); To embed your video, here are some resources: https://processwire.com/talk/topic/4580-video-fieldtype/https://processwire.com/talk/topic/7380-whats-your-favourite-video-embedder-and-why/ https://processwire.com/talk/topic/4956-addinguploading-audiovideo-files-to-pages-media-manager/?p=48085 https://processwire.com/talk/topic/4956-addinguploading-audiovideo-files-to-pages-media-manager/?p=48126 You might also be able to use the Comments Fieldtype and the Comments Manager (with recent updates here, here and here) so that clients can add some comments to the video and encourage each other. Anyway, take these suggestions as you wish. I just love thinking about how to structure a site 2 Link to comment Share on other sites More sharing options...
tuxy Posted March 10, 2015 Author Share Posted March 10, 2015 Hi ESRCH! Wauw! Lots of information! Yes, the start of a project is very special with PW, it is the foundation of the whole project! For now I have a lot of time for developing this project (deadline is end of the summer!), but i want preparations and searching for good solutions. In this forum are the experts with PW, and some advice how to start this project is welcome. I like your information, gives me a lot of hope how to start this project, and for myself it is a good way learning PW Grtz, Christophe Link to comment Share on other sites More sharing options...
tuxy Posted March 11, 2015 Author Share Posted March 11, 2015 user template? you mean the profile-page? Link to comment Share on other sites More sharing options...
mr-fan Posted March 11, 2015 Share Posted March 11, 2015 Nope User template... take a look at edit templates at the top ->filter ->show system templates.....in PW the backend is not really more than the frontend... So you can add fields to the user template like a pagefield! So now there are many options again.... 1. should the admin set the users to the videos or 2. should the admin set the videos for the user it's a kind of usability question here....so how many users how many videos? Option 2 should be the best since it all depends personally - so you could create a little special admin page to let the coach choose first which user and then add some videos all on one page. Take also a look at http://modules.processwire.com/modules/process-admin-custom-pages/ Oooooh, I love this moment when you first think about the possible structure of a website, and all the great things you can do with it, it's awesome this is unique with PW while you have all options on your side.... 3 Link to comment Share on other sites More sharing options...
ESRCH Posted March 11, 2015 Share Posted March 11, 2015 The user template and the profile page are not quite the same thing: The "user" template is basically similar to any other template in Processwire. In the same sense that you might have a "product" template with fields "reference", "title" and "price", you have a "user" template with fields "email", "pass" (for password) and "roles". You can see this template by going in Setup > Templates, then expanding "Filters" > "Show system templates?" and choosing "Yes". The "user" template then appears, and when you click on it, you can see that it has different fields, and that you can add fields to it (for example "selected_videos"). When editing a user (Access > Users), you can see all these fields and edit them. This is managed by the ProcessPageEdit module, which is the same as for all other pages. The profile page is a special page which shows only a few fields (e-mail and password) for the logged in user. This is managed by the ProcessProfile module. So in your case, you can simply add the "selected_videos" to the user template, so that the coach can attribute videos to each user. 2 Link to comment Share on other sites More sharing options...
ESRCH Posted March 11, 2015 Share Posted March 11, 2015 @mr-fan, Indeed, ProcessWire is quite unique in that you never feel that something is too difficult to do from the outset. I explored Drupal a little before, and there were many times when I was wondering how to approach a project. PW is very open and allows you to have a very consistent structure in your project (Fields > Templates > Pages). And the hook system is very well done to be able to expand the CMS when needed. I do love this CMS 4 Link to comment Share on other sites More sharing options...
tuxy Posted March 11, 2015 Author Share Posted March 11, 2015 Nope User template... take a look at edit templates at the top ->filter ->show system templates.....in PW the backend is not really more than the frontend... So you can add fields to the user template like a pagefield! So now there are many options again.... 1. should the admin set the users to the videos or 2. should the admin set the videos for the user it's a kind of usability question here....so how many users how many videos? Option 2 should be the best since it all depends personally - so you could create a little special admin page to let the coach choose first which user and then add some videos all on one page. Take also a look at http://modules.processwire.com/modules/process-admin-custom-pages/ this is unique with PW while you have all options on your side.... Ok, Hiiiii, Thats nice! system templates are new for me This gives me a lot of possibilities. Client x can see 6 videos. Cleint y can see 15 videos. It is different / client. Hmm, i look in the next days to the custom module. thx for the tip! I'm very motivated start this project, with this uselful information. Thank you guys If you has more useful tips, i follow this topic Christophe Link to comment Share on other sites More sharing options...
tuxy Posted March 11, 2015 Author Share Posted March 11, 2015 But... I think it's better make a new page 'My personal fitness program' / user? Or is it better edit the system template? @mr-fan, This what the coach want: Point 2: should the admin set the videos for the user Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 11, 2015 Share Posted March 11, 2015 The more flexible way would be to use the user template only for "userdata" and just use a pagefield to link each user to a section of the page where his fitness program is located. This way it's easier if you later decide that maybe a user could have more than one fitnessplan or something like that. It's kinda like in object oriented programming: A fitnessprogram is an object and a user is an object (already the case in pw), so it's the easiest to structure it this way in the backend, too. 2 Link to comment Share on other sites More sharing options...
ESRCH Posted March 11, 2015 Share Posted March 11, 2015 Yes, that's an interesting approach, and very flexible. A concrete way of doing this could be to create a fitness-program template, with a title field, a videos multi-page field and a description textarea field. You can then create a PageTable field called fitness_programs that uses that fitness-program template, and add it to the user template. This way, the coach can create for example weekly or monthly programs by adding a fitness program to a user like this: Title: Week #1 Videos: Video 1, Video 4, Video 5 Description: Do 5 times: Crunches 20x Push-ups 15x Chin-ups 12x 2 Link to comment Share on other sites More sharing options...
tuxy Posted March 11, 2015 Author Share Posted March 11, 2015 The more flexible way would be to use the user template only for "userdata" and just use a pagefield to link each user to a section of the page where his fitness program is located. This way it's easier if you later decide that maybe a user could have more than one fitnessplan or something like that. It's kinda like in object oriented programming: A fitnessprogram is an object and a user is an object (already the case in pw), so it's the easiest to structure it this way in the backend, too. Ok, I try understand what you mean, but it's not so easy whithout example/code-snippet how realise that. If I can follow you, then added a reference-link-field to the selected videos in the user-template? Fitness Program Project: 1.The first step is uploading ALL the videos. -Videos --Video1 --Video2 ... 2. The coach adding users -Users --User1 --User2 3. The coach selected the videos for each user/client (personal fitness program) ... (I made my first PW project with success (www.springbeestjes.be) and now understanding the basics, but there is a lot more that I want to learning for building great PW sites!) Christophe Yes, that's an interesting approach, and very flexible. A concrete way of doing this could be to create a fitness-program template, with a title field, a videos multi-page field and a description textarea field. You can then create a PageTable field called fitness_programs that uses that fitness-program template, and add it to the user template. This way, the coach can create for example weekly or monthly programs by adding a fitness program to a user like this: Title: Week #1 Videos: Video 1, Video 4, Video 5 Description: Do 5 times: Crunches 20x Push-ups 15x Chin-ups 12x Yes, that would be nice, and very flexible Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 11, 2015 Share Posted March 11, 2015 It's like this: - Videos - Video - Video - Video - Fitness Programs - Program - Program - Program - Users - User - User You upload all the videos, than you create users and then you can create the program for each user. This program has some pagefield where the trainer can chose the videos for the program (e.g. videos) and a pagefield to select which user this program relates to (e.g. user). Then you can use selectors like this: $pages->get("template=program, user=$user")->videos; // Get all videos from this users program $pages->find("template=program, videos=$someVideoID"); // Get all programs featuring this one video 4 Link to comment Share on other sites More sharing options...
ESRCH Posted March 11, 2015 Share Posted March 11, 2015 I like this kind of discussion Separating the fitness programs is a good idea, especially if they are reusable (can be attributed to different users). However, the problem with including a "user" field in the fitness-program template rather than a fitness_program field in the user template, is that it isn't possible to control the order in which the programs appear. The only available sorting mechanism would be from oldest to newest (or the opposite) by sorting by id. If the coach decides at some point that he wants to reuse the fitness programs, he can't set the order of the programs per user. So I would argue in favor of having a fitness_program field in the "user" template 1 Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 11, 2015 Share Posted March 11, 2015 Why shouldn't it be sortable by user? But regarding "finding the right program" you can set up the program template to not only show it's title in the page tree, but also the users name. 1 Link to comment Share on other sites More sharing options...
ESRCH Posted March 11, 2015 Share Posted March 11, 2015 Let's say you have two users with the following sets of programs (for different weeks for example): - User 1: Program 1 (Week 1), Program 3 (Week 2), Program 7 (Week 3) - User 2: Program 3(Week 1), Program 4 (Week 2), Program 1 (Week 3) Now on the front-end, you need to show him his program by week: "Dear User 1, Here is your weekly program for the next month: Week #1: Program 1 Week #2: Program 3 Week #3: Program 7" Well, by defining the link to the user on the program template, you can't define in which order the programs can be sorted for a specific user, since the only selector you could use would be: $programs = $pages->find("template=program, user=$user, sort=??"); But we might be going a little off-topic here and mixing up Christophe 1 Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 11, 2015 Share Posted March 11, 2015 You're right you can't sort them by simple drag and drop of programs. If you need this you'd do it the other way around, prepare programs independent of users and assing them to the user template via a page field. 1 Link to comment Share on other sites More sharing options...
tuxy Posted March 12, 2015 Author Share Posted March 12, 2015 It's like this: - Videos - Video - Video - Video - Fitness Programs - Program - Program - Program - Users - User - User You upload all the videos, than you create users and then you can create the program for each user. This program has some pagefield where the trainer can chose the videos for the program (e.g. videos) and a pagefield to select which user this program relates to (e.g. user). Then you can use selectors like this: $pages->get("template=program, user=$user")->videos; // Get all videos from this users program $pages->find("template=program, videos=$someVideoID"); // Get all programs featuring this one video Ok, a stupid question: if I can follow: if the user logged in, then the program-page (template) is showing related with the user? Not the standard user-page (user-template)? Thanks for the snippet-examples LostKobrakai I learning best with this! Link to comment Share on other sites More sharing options...
tuxy Posted March 12, 2015 Author Share Posted March 12, 2015 Hi guys, I'm impressed with all this information I'm very happy with this! The project is not for now it is for this summer! But I have an idea how can started, and have a few questions to ask the fitnesscoach about sorting, etc. PS: I can not enough saying that your very helpful people and I think this make the PW community very strong and popular! I very very very happy I find PW when I searching for the best CMS A happy (junior) PW-user, Christophe 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now