Hi there,
thank you for this great package!
One thing I could not figure out is how to add a custom atom:link entry to a feed?
I want to add entry like this :
<atom:link href=“https://www.example.org ” rel=“alternate” type=“text/html”/>
Any ideas are welcome. Thank you.
Hello and welcome to our forums!
Add a link to the entry:
$entry->setLink('http://www.example.com/article');
This will produce:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<!-- … -->
<entry>
<link rel="alternate" type="text/html" href="http://www.example.com/article"/>
<!-- … -->
</entry>
</feed>
This is the same as:
<?xml version="1.0" encoding="utf-8"?>
<atom:feed xmlns:atom="http://www.w3.org/2005/Atom">
<!-- … -->
<atom:entry>
<atom:link rel="alternate" type="text/html" href="http://www.example.com/article"/>
<!-- … -->
</atom:entry>
</atom:feed>
But you can avoid the namespace.
protected function _setLink(DOMDocument $dom, DOMElement $root)
{
// @codingStandardsIgnoreEnd
if (! $this->getDataContainer()->getLink()) {
return;
}
$link = $dom->createElement('link');
$root->appendChild($link);
$link->setAttribute('rel', 'alternate');
$link->setAttribute('type', 'text/html');
$link->setAttribute('href', $this->getDataContainer()->getLink());
}
Thank you @froschdesign !
I guess I forgot to mention that I export the feed in RSS format (for podcasts) and that I want multiple links. It seems I can have only one link and it exports as this:
<link>https://www.example.org</link>
Do mean Apple Podcasts ? It is based on RSS 2.0 and only one link element is allowed here.
Do you have concrete use case for more than one link? Is there a reader or player that understands multiple links?
That is why I asked for the link with the atom prefix. It should allow more than one.
I want to use it internally to pass on locations where the podcast can be found / subscribed to (podcast portals and aggregators).