Wrong metatags - main description used not the one from menu items 7 years 2 weeks ago #1

  • Uyttebroeck Michel
  • Localtime: 18:21
  • Europe/Bucharest
  • Posts: 15
Hi,

I have a big problem with the component and the metatags used in the page.

The com_hotornot uses the general metatags located in the general configuration and not the metatags added within the menu item.

My site runs in two languages and for each language, within the main menu, I have a link pointing to the gallery. Each menu item have their own metatags.

How can I modify this detail which for my client is a real problem.

Many thanks
Michel
The administrator has disabled public write access.

Re: Wrong metatags - main description used not the one saved within the menu item 7 years 2 weeks ago #2

  • Alexandru
  • Alexandru's Avatar
  • Senior Developer
  • Bucharest
  • Localtime: 18:21
  • Europe/Bucharest
  • Posts: 4642
Hello!

This feature is not implemented. Here is a quick tweak: edit [Joomla dir]\components\com_hotornot\controller.php and append to the "__construct" function the following:
$active = JFactory::getApplication()->getMenu()->getActive();
    if ($active) {
      $document = JFactory::getDocument();

      if ($active->params->get('menu-meta_keywords')) {
        $document->setMetadata('keywords', $active->params->get('menu-meta_keywords'));
      }

      if ($active->params->get('menu-meta_description')) {
        $document->setDescription($active->params->get('menu-meta_description'));
      }
    }
thePHPfactory Customer Support
The administrator has disabled public write access.

Re: Wrong metatags - main description used not the one saved within the menu item 7 years 2 weeks ago #3

  • Uyttebroeck Michel
  • Localtime: 18:21
  • Europe/Bucharest
  • Posts: 15
Hi Alex,

Many thanks for the quick answer.

Here is the script:

  function __construct()
  {
    require_once('helper.php');
    require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_hotornot'.DS.'settings.php');
    require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_hotornot'.DS.'fcounter.php');

    parent::__construct();
  }

Should it be like this with your tweek:


  function __construct()
  {
    require_once('helper.php');
    require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_hotornot'.DS.'settings.php');
    require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_hotornot'.DS.'fcounter.php');

$active = JFactory::getApplication()->getMenu()->getActive();
    if ($active) {
      $document = JFactory::getDocument();

      if ($active->params->get('menu-meta_keywords')) {
        $document->setMetadata('keywords', $active->params->get('menu-meta_keywords'));
      }

      if ($active->params->get('menu-meta_description')) {
        $document->setDescription($active->params->get('menu-meta_description'));
      }
    }

    parent::__construct();
  }

Let me know
Many thanks (I am not really a dev, so I am confused when it comes down to coding :-)
The administrator has disabled public write access.

Re: Wrong metatags - main description used not the one saved within the menu item 7 years 2 weeks ago #4

  • Alexandru
  • Alexandru's Avatar
  • Senior Developer
  • Bucharest
  • Localtime: 18:21
  • Europe/Bucharest
  • Posts: 4642
Yes, that is correct.
thePHPfactory Customer Support
The administrator has disabled public write access.

Re: Wrong metatags - main description used not the one saved within the menu item 7 years 2 weeks ago #5

  • Uyttebroeck Michel
  • Localtime: 18:21
  • Europe/Bucharest
  • Posts: 15
Hi Alex,

It works in the gallery view (browse) - not within the detail view. (show)
Is there any file to be amended to apply it within the detail view ?

Again thanks a lot for your support
Michel
The administrator has disabled public write access.

Re: Wrong metatags - main description used not the one from menu items 7 years 1 week ago #6

  • Alexandru
  • Alexandru's Avatar
  • Senior Developer
  • Bucharest
  • Localtime: 18:21
  • Europe/Bucharest
  • Posts: 4642
Move the code you just added to the [Joomla dir]\components\com_hotornot\hotornot.php file, just after
$user =& JFactory::getUser();
thePHPfactory Customer Support
The administrator has disabled public write access.