Hi,

I have a view of course (currently 4 different course). On the page I have an image, into text and 2 links. One link is "read more" and the other is "Enrol Now"
Read more = course page
Enrol Now = link to node/[nid]/takecourse

I want to make the "Enrol Now" link smarter and display "Continue Course" if the user has already enrolled in the course.

What's the best way to do this using views?

Comments

djdevin’s picture

What I would do is

1) A view with a list of courses (node)
2) Add relationship from Node -> Enrollment (do not check "require relationship")
(now this is a list of all nodes, joined to all enrollments)
3) Add a contextual filter on Enrollment UID (the current user)

Now you have a view of courses, joined to the users enrollments.

4) Add the Enrollment ID field
5) Rewrite the enrollment ID field and create a link with views replacements. Empty text would mean that the user is not enrolled. Anything else would mean that they are enrolled. You can use tokens from any field to construct a link.

djdevin’s picture

Status: Active » Closed (fixed)