Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// This is a module method. Use it like so...
// {exp:module_name:class_achievements course_url_title="{segment_3}"}
public function class_achievements()
{
// Course is a model I created. findUrlTitle() is an inherited static method
if(!$course = Course::findByUrlTitle($this->param('course_url_title')))
{
// If no course is found, return the noResults() method.
return ChannelEntriesParser::noResults();
}
// Achievements is another model that is related to courses. Course
// has a method name achievements to fetch these related models.
if(!$achievements = $course->achievements())
{
// And if no achievements, return noResults() method.
return ChannelEntriesParser::noResults();
}
// If all is successfully, return the related achievements as a Channel Entries loop
return $achievements->entries();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment