Hey,

I was wondering if there is any way to display course object fields to be shown on course outline page. Lets say, I have 5 course content for a particular course. And I want to display a brief description of each course object on course outline page. I create a text field under link - admin/course/object/fields. The field shows for each course object on object-edit page. How can I show this field on course outline page?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

djdevin’s picture

If you go to admin -> course -> objects -> manage fields, you can add a description field which will be shown on all course object configurations.

For now, you would then have to use the same theme functions in #2277331: Display Course Object Fields on Outline Page for them to appear in the list.

In the future there will be a view mode for course objects in the outline, so the theme override will not be necessary.

smits.smiling@gmail.com’s picture

Yes, I am trying to use function mythemename_course_outline_item. I can get the course object node title using $object->getTitle(). How do I fetch the new custom field that I created using admin -> course -> objects -> manage fields.

djdevin’s picture

Hi,

Try this

    $entity = entity_load_single('course_object', $object->getId());
    $custom_field = field_view_field('course_object', $entity, 'field_my_custom_field');
    $html = drupal_render($custom_field);
smits.smiling@gmail.com’s picture

That's awesome. The code worked very well. Thanks for all the help. :)

djdevin’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Category: Support request » Feature request
Status: Active » Needs review
FileSize
2.6 KB

Use entity_view for item outlines.

sibopa’s picture

Hi;
Thanks a lot for your great job on this module;
I've applied this path and am having a "undefined index" error on this line:
$co = entity_load_single('course_object', $object->getid());
return drupal_render(entity_view('course_object', array($co)));

Also, I think it will be more efficient to use a field on the content type used as course object instead of the entity?
for example, use the body field of the content type since the course creator almost always fill it?

Thanks again.

djdevin’s picture

This patch is old so it may need some more testing.

This is for per-course object fields - when you want different values for a field for each course object, like an "estimated time to complete" for each step. Or, if you wanted a custom image to appear per object, things like that.

Status: Needs review » Needs work

The last submitted patch, 5: display_course_object-2277331-5.patch, failed testing.

sibopa’s picture

Do we have a new version of the patch?

sibopa’s picture

I was able to get field to show up using your post #3 above. Is it possible to achieve something similar with field from the object node instead?
Let's say I have a content type "document" set as a "course content" that has a field "description".
How can I alter this

    $entity = entity_load_single('course_object', $object->getId());
    $custom_field = field_view_field('course_object', $entity, 'field_my_custom_field');
    $html = drupal_render($custom_field);

to display the "description" field teaser in the course outline?

djdevin’s picture

Status: Needs work » Needs review
FileSize
2.61 KB
djdevin’s picture

djdevin’s picture

Status: Needs review » Needs work

The last submitted patch, 14: display_course_object-2277331-14.patch, failed testing.

djdevin’s picture

Status: Needs review » Needs work

The last submitted patch, 16: display_course_object-2277331-14.patch, failed testing.

djdevin’s picture

Status: Needs review » Needs work

The last submitted patch, 18: display_course_object-2277331-18.patch, failed testing.

The last submitted patch, 18: display_course_object-2277331-18.patch, failed testing.

djdevin’s picture

djdevin’s picture

Status: Needs review » Fixed

Committed.

Course objects use entity view now.

  • djdevin committed d288cd4 on 7.x-1.x
    Issue #2277331 by djdevin: Display Course Object Fields on Outline Page
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.