New category/course view for pay for access

New category/course view for pay for access

by Chardelle Busch -
Number of replies: 5
Picture of Core developers

Hi all,

I have a site set up with 3 categories and view a list of courses for the site settings--so it brings up the course titles with little icons. (See image--this is a case where an enrollment key is given to employees for some things, but they have to pay for other stuff). 

I have added to the course>lib.php file so that if a course has a cost, it will put up a $ icon instead of the key icon.  (will submit it next post). 

The problem is for some reason I couldn't get it to read the requirespayment string for the mouseover on the icon (so have just added the text for now).  If somebody wants to check into that it would be helpful.  Otherwise, you can use this code as is. 

Attachment Untitled-1.gif
Average of ratings: -
In reply to Chardelle Busch

Re: New category/course view for pay for access

by Chardelle Busch -
Picture of Core developers

Here's the cost icon that will need to be added to pix>i>.

Here's the code to be added (the file is a little too big to submit)

Add this code (about line 1180) instead of the If course-> password section:

 if ($course->cost) {
                    echo "<a title=\"$strrequirespayment\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
                   echo "<img hspace=1 alt=\"This course requires payment for access\" height=16 width=16 border=0 src=\"$CFG->pixpath/i/cost.gif\"></a>";
                } else if($course->password) {
    
                    echo "<a title=\"$strrequireskey\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
                    echo "<img hspace=1 alt=\"$strrequireskey\" height=16 width=16 border=0 src=\"$CFG->pixpath/i/key.gif\"></a>";
     
                } else {
                    echo "<img alt=\"\" height=16 width=18 border=0 src=\"$CFG->pixpath/spacer.gif\">";
                            

Attachment cost.gif
In reply to Chardelle Busch

Re: New category/course view for pay for access

by N Hansen -
Chardelle-An alternative would to just make it a dollar sign (in text, not image), and use css to cause the dollar sign to change color/become bold or whatever other effect you want it to have on mouse-over. You could also use css to set the exact size of the dollar sign in pixels so that it matches the other icon next to it. No need for an actual icon.
In reply to N Hansen

Re: New category/course view for pay for access

by Chardelle Busch -
Picture of Core developers

With this code, which is intended to "match" the code for other icons to keep things in php, the $ sign -- which could be smaller cause the key is pretty small- replaces the key if the course has a cost.  I don't want the key coming up also--that seems redundant if the course has a cost.  Also, this code includes a mousever string - requirespayment - that is already in the lang file.  Although I had added that get_string to the code (which doesn't show up in the above code), it didn't work for some reason.

In reply to Chardelle Busch

Re: New category/course view for pay for access

by N Hansen -
All you have to do is replace the image of the dollar sign, with the text of a dollar sign, and apply whatever CSS you want to it, if your theme doesn't already have a mouseover effect for links encoded. They key won't show up, you simply will get a text dollar sign instead of an image. 
In reply to N Hansen

Re: New category/course view for pay for access

by Chardelle Busch -
Picture of Core developers
Well, what I have done works for me, so I leave it like that--I don't want to get into CSS.