A
A
alienwaree2015-10-30 13:47:49
CMS
alienwaree, 2015-10-30 13:47:49

Change favicon.ico link in Joomla 3 (PHP)?

The essence of the problem is that favicon.ico is not displayed in Yandex search. There are similar topics on the Internet, but there is no word about Joomla 3.
As I understand it, to display a favicon in Yandex, you need a link to favicon.ico in the root of the site.
My favicon.ico is located in the subfolders of the site, and manually through the CMS it is impossible to specify that favicon.ico lies at the root and not, for example, in the /images folder where the template developers stuffed it.
Having rummaged in the template, I found a php file from where the site takes its favicon. But how to make it so that it would take from another place so that Yandex would finally pick up my favicon and start displaying it in the search.
I am attaching the php code:

// Try to find a favicon by checking the template and root folder
    $path = $directory . '/';
    $dirs = array($path, JPATH_BASE . '/');
    foreach ($dirs as $dir)
    {
      $icon = $dir . 'favicon.ico';
      if (file_exists($icon))
      {
        $path = str_replace(JPATH_BASE . '/', '', $dir);
        $path = str_replace('\\', '/', $path);
        $this->addFavicon(JUri::base(true) . '/' . $path . 'favicon.ico');
        break;
      }
    }

How it looks in HTML code:
Не нужно:
<link href="/templates/vt_marketing/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
Надо вот так:
<link href="www.сайт.ru/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" /><code lang="html">
</code>

Буду безмерно благодарен за любую оказанную помощь!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin, 2018-05-11
@Kotkech

There is such a file \libraries\src\Document\HtmlDocument.php
It really has such a code snippet.
So, I'm in the line $path = str_replace(JPATH_BASE . '/', '', $dir);
deleted everything after JPATH_BASE it turned out like this $path = str_replace(JPATH_BASE);
After I threw the icon file into the root of the site and everything worked out.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question