Automattic / sensei

Sensei LMS - Online Courses, Quizzes, & Learning
https://senseilms.com
GNU General Public License v2.0
540 stars 198 forks source link

Improve template files #658

Closed danjjohnson closed 8 years ago

danjjohnson commented 9 years ago

Template files should handle display only, not logic. Add suggestions for improvement as comments here.

danjjohnson commented 9 years ago

https://support.woothemes.com/hc/communities/public/questions/201993345--BUG-Future-Update-Output-of-My-Courses-List-Under-My-Account-Not-Within-Editable-Templates

Currently the Course Listings created on the My Courses page is output by the function load_user_courses_content defined within /classes/class-woothemes-sensei-course.php

One of my clients has requested I remove certain items within this view...

I'm making the modifications my client has requested within the /classes/class-woothemes-sensei-course.php but I know these changes will eventually be overwritten when we update Sensei next...

So, I would like to suggest that the output of the load_user_courses_content function that creates the My Courses list should be able to be modified as part of a theme's Sensei templates... should be pretty easy to accomplish since you already provide loop-course.php

Anyhow, just wanted to make WooThemes aware of this so that you could add it to the list of modifications to potentially make this change in a future update.

davecpage commented 9 years ago

We have extended this without changing the core function.

Copy the existing load_user_courses_content() to a separate file. Suggest something within the current theme. Then copy the woothemes-sensei/templates/user/my-courses.php file as [theme-name]/sensei/user/my-courses.php so Sensei uses that file. Edit the new my-courses file to refer to the copied function and start editing.

We changed the function so that users can't manage their Courses from the resultant screen (as course signups are all automatic), but also to show extra custom fields we add to Courses.

As a BuddyPress aside, we have a custom component which simply calls the shortcode [usercourses] to load the My Courses page within a users profile. As people can view anyones profile we further changed the custom my-courses.php template to detect that it was in this new BuddyPress component and if so switch from passing the current user into the custom load_user_courses_content() to instead use whatever the user is that is being viewed in BuddyPress. This means that anyone can view anyones My Courses page seeing how far everyone has got.

You could have it so that in the my-courses.php template it's a do_action rather than a direct call, which would allow someone to remove the default add_action and attach a custom action instead. It's not much different than what I mention above though.

dwainm commented 8 years ago

Fixed as part of 1.9.0