Best practice forum (Archived)

This forum discussion has been removed

 
This forum post has been removed
Thursday, 26 September 2013, 7:29 PM
The content of this forum post has been removed and can no longer be accessed.
David Curry (Core Developer)
Re: Adding Anchors to course pages
by David Curry (Core Developer) - Sunday, 29 September 2013, 6:13 PM
Group Totara

Hi Marni,

What are you trying to do here? if you are trying to create a link to a particular section within a course this is easily done by adding "#section-X" to the end of the course url, for example localhost/2_4/course/view.php?id=99#section-4 would take me to the fourth week within a weekly formated course (not including the header section containing the default news forum). Other than that you could add a label where you want the anchor and make the html for that label look something like
"<p><a name="anchor">Your text here</a></p>" matched with a url like "localhost/2_4/course/view.php?id=99#anchor", the same could also be done inside a section summary or any tinymce field that shows on the course page.

Also if you want to use anchors within a document I found a moodle example here http://www.youtube.com/watch?v=S1qgb81Diyk

Hope that helps,
David

David Curry (Core Developer)
Re: Adding Anchors to course pages
by David Curry (Core Developer) - Sunday, 29 September 2013, 6:56 PM
Group Totara

Ah hah, I looked into this a bit more since having to use the html editor to add an anchor tag seemed a little odd when you can create hyperlinks with the click of a button. It looks like the anchor button, shown in the youtube video linked in my previous post, dissapeared between Totara 1.1 and Totara 2.2. This was addressed in 2.4 by adding the ability to customise the toolbar for tinymce editors, and the anchor button could be re-added by making these changes.
Site administration > plugins > text editors > TinyMCE HTML editor > General settings > Editor toolbar
Change the line like so:
- bullist,numlist,outdent,indent,|,link,unlink,|,image,nonbreaking,charmap,table,|,code
+bullist,numlist,outdent,indent,|,anchor,link,unlink,|,image,nonbreaking,charmap,table,|,code

More info about that here: http://docs.moodle.org/24/en/Text_editor#Customising_the_editor_toolbar

However you are on 2.2 so this would require a tiny customisation of the code, it's almost exactly the same as the 2.4 setting but in the code, lib/editor/tinymce/lib.php around line 142
- 'theme_advanced_buttons3' => "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink, ...
+'theme_advanced_buttons3' => "bullist,numlist,outdent,indent,|,anchor,link,unlink,moodlenolink, ...

I thought that might be a more satisfactory solution than having to directly edit the html of an item every time.

Cheers
David

This forum post has been removed
Sunday, 29 September 2013, 7:51 PM
The content of this forum post has been removed and can no longer be accessed.