Named Anchor

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
vscheer
Posts: 7
Joined: Thu Aug 15, 2019 6:23 pm

Named Anchor

Post by vscheer »

Script URL:
Version of script: 2.8.2
Hosting company: HostingMatters
URL of phpinfo.php: 7.1.31 (MySQLi)
URL of session_test.php:
What terms did you try when SEARCHING for a solution: Anchor

Write your message below:
Article: https://www.pbgv.org/help/knowledgebase.php?article=4
I tried to add anchors within text linked from TOC at top:
HTML editor is stripping out the correct coding that I have brought over from Dreamweaver and it does the same when using HTML editor.

Table on Contents should be:
<a href="#spay" title="Will I need to spay or neuter my dog">Will I need to spay or neuter my dog?</a>
Editor changes to this:
<a title="Will I need to spay or neuter my dog" href="#spay">Will I need to spay or neuter my dog?</a>

For Destination anchor the code just disappears from source code. I have tried to enter using the HTML editor and it is gone no matter what I've tried. The code that needs to be next to that specific question is <a name="spay" id="spay"></a>.

Why is the named anchor being stripped out and what can I do to solve. FYI, just started setting this up for my PBGV club and am learning.
Thanks, Veronica
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Re: Named Anchor

Post by Klemen »

The issue is HTMLPurifier (a third party sanitation library Hesk uses) removes name and id tags by default.

To change this behavior:

1. backup existing files
2. open inc/htmlpurifier/HeskHTMLPurifier.php in a powerful text editor, such as Notepad++
3. find this code:

Code: Select all

$config = HTMLPurifier_Config::createDefault();
Just BELOW that add

Code: Select all

$config->set('Attr.EnableID', true);
4. save, upload and test
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
vscheer
Posts: 7
Joined: Thu Aug 15, 2019 6:23 pm

Re: Named Anchor

Post by vscheer »

Thanks for info. Tried and it is still stripping out anchor coding. Have returned original file and now have an issue in knowledgebase. When I save the article, system does not return back to interface. It calls for manage_knowledgebase.php; however, does not resolve, just blank page. I can get back by go back to admin page. Not sure what that is about. Using Notepad, I added the coding in the following: inc/htmlpurifier/HeskHTMLPurifier.php and it looked like below.

public function heskPurify($content)
{
$config = HTMLPurifier_Config::createDefault();
$config->set('Attr.EnableID', true);
$config->set('Attr.AllowedRel', array('follow', 'referrer', 'nofollow', 'noreferrer') );
$config->set('Attr.AllowedFrameTargets', array('_blank', '_self', '_parent', '_top') );
$config->set('Cache.SerializerPath', $this->cacheDir);
$config->set('URI.AllowedSchemes', array(
'http' => true,
'https' => true,
'mailto' => true,
'ftp' => true,
'nntp' => true,
'news' => true,
'tel' => true,
'data' => true,
)
);

if ($this->allowIframes)
{
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Re: Named Anchor

Post by Klemen »

That code looks fine, maybe a problem elsewhere? Try uploading original files, you can get 2.8.2 ones at https://www.hesk.com/download-legacy.php

If no luck, turn "Debug mode" ON in Hesk settings > Help desk tab > under Features and see if you get an error message when saving an article.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
vscheer
Posts: 7
Joined: Thu Aug 15, 2019 6:23 pm

Re: Named Anchor

Post by vscheer »

I updated to version 2.8.4, re-added the additional code in the inc/htmlpurifier/HeskHTMLPurifier.php file, and turned on debug. Then tried using the HTML editor and added article coding created in dreamweaver...this did not work. However, it did retain the table of contents link and I manually added anchor using purifier interface and it seems to be working. Will try a few more links in article and hope all is well, Thank you, Veronica
Post Reply