How to auto-create links from headings in articles?

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Post Reply
tukusejssirs
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sat Mar 16, 2019 9:30 pm

How to auto-create links from headings in articles?

Post by tukusejssirs » Sat Mar 16, 2019 9:46 pm

I would like to have hyperlinks to headings in articles automatically created on my website. What I mean is the following:

On https://example.com, there is an article http://example.com/article and in that article there is quite long text that is divided into smaller parts by headings (Heading 1 through Heading 4). On some websites on the Internet, I’ve seen that it is possible as https://example.com/article#heading, however in Joomla 3 I have no idea how to accomplish this.

Is it possible using core Joomla 3 functionalities or via some module only?

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 25660
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: How to auto-create links from headings in articles?

Post by Per Yngve Berg » Sat Mar 16, 2019 9:57 pm


tukusejssirs
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sat Mar 16, 2019 9:30 pm

Re: How to auto-create links from headings in articles?

Post by tukusejssirs » Sun Mar 17, 2019 10:59 am

Thank you for your answer, however this is what I meant → https://stackoverflow.com/a/2835151/3408342

However, I cannot add to the article source code line `<h1 name="foo">Heading<\h1>` nor `<h1 div="foo">Heading</h1>`

Is there a way to accomplish it? Do I need to toggle some kind of setting?

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 25660
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: How to auto-create links from headings in articles?

Post by Per Yngve Berg » Sun Mar 17, 2019 11:58 am

Joomla does not use anchor points natively. Inside the article, you can type the html in the editor. Toggle the editor into html mode. Start with h3, as h1 and h2 is used for the Page Title and Article Title.

https://www.w3schools.com/html/html_links.asp

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 25660
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: How to auto-create links from headings in articles?

Post by Per Yngve Berg » Sun Mar 17, 2019 12:12 pm


tukusejssirs
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sat Mar 16, 2019 9:30 pm

Re: How to auto-create links from headings in articles?

Post by tukusejssirs » Sun Mar 17, 2019 1:09 pm

I tried to add `<h3 id="test">test</h3>` to a long article after toggling the html viewer to source code, however, after clicking on Save, Joomla automatically removes that line.

I still need to check upon the extension.

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 25660
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: How to auto-create links from headings in articles?

Post by Per Yngve Berg » Sun Mar 17, 2019 1:40 pm

I don't have a problem with that using the JCE Editor.

Did you insert it so it's not inside another tag?

tukusejssirs
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sat Mar 16, 2019 9:30 pm

Re: How to auto-create links from headings in articles?

Post by tukusejssirs » Sun Mar 17, 2019 1:50 pm

No, I inserted it between two paragraphs (i.e. after </p> and before <p>).

I’ve just tested it out in a ‘real’ article (using Article → Content, New) and it worked.

However, I need it to work in ToS withing VirtueMart 3, where it does not work (right after clicking on Save, it removes the line). This might not be connected directly with Joomla 3.


Post Reply

Return to “General Questions/New to Joomla! 3.x”