How to show meta robot index, follow and meta description through preparedocument

Discuss Search Engine Optimization in relation to Joomla! 3.x. This forum will also have discussions on SEF/SEO Joomla! 3.x extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
mch79
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Wed Jul 22, 2015 7:25 am

How to show meta robot index, follow and meta description through preparedocument

Postby mch79 » Tue Sep 05, 2017 2:54 am

I have below _preparedocument for generating meta tags
Although am able to generate title, but unable to make robot index,follow

so how to make
> robots index, follow in it using this _preparedocument function
> Description which is stored in $this->CatDescript show as meta description of the page

can any one suggest and help in pls

**Below is Preparedocument function**

Code: Select all

    /**
    * Prepares the document
    *
    * @return void
    *
    * @throws Exception
    */
    protected function _prepareDocument()
    {
    $app = JFactory::getApplication();
    $menus = $app->getMenu();
    $title = null;
   
   
    // Because the application sets a default page title,
    // We need to get it from the menu item itself
    $menu = $menus->getActive();
   
    if ($menu)
    {
    $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
    }
    else
    {
    $this->params->def('page_heading', JText::_('COM_USEDCAR_DEFAULT_PAGE_TITLE'));
    }
   
    $title = $this->params->get('page_title', '');
   
    if (empty($title))
    {
    $title = $app->get('sitename');
    }
    elseif ($app->get('sitename_pagetitles', 0) == 1)
    {
    $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title);
    }
    elseif ($app->get('sitename_pagetitles', 0) == 2)
    {
    $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename'));
    }
   
    $title = $this->CatName;
    $this->document->setTitle($title);
   
    if ($this->params->get('menu-meta_description'))
    {
    $this->document->setDescription($this->params->get('menu-meta_description'));
    }
   
    if ($this->params->get('menu-meta_keywords'))
    {
    $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
    }
   
    if ($this->params->get('robots'))
    {
    $this->document->setMetadata('robots', $this->params->get('robots'));
    }
    }
    }
    ?>

User avatar
sozzled
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3290
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia
Contact:

Re: How to show meta robot index, follow and meta description through preparedocument

Postby sozzled » Tue Sep 05, 2017 8:51 am

This code will not create a <META ROBOTS ...> tag if the value of $this->params->get('robots') is unset/false. In your plugin settings (the .XML file) what value are you using for the robots parameter?
https://www.kuneze.com/blog
Former member of Kunena project team
If you think I’m wrong then say “I think you're wrong.” If you say “You’re wrong!”, how do you know?

mch79
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Wed Jul 22, 2015 7:25 am

Re: How to show meta robot index, follow and meta description through preparedocument

Postby mch79 » Tue Sep 05, 2017 2:16 pm

Hello,

This is a custom component build through component creator
I checked but there is no plugin which is associated with it

Can you direct in how to add
> robots index, follow in it using this _preparedocument function
> Description which is stored in $this->CatDescript show as meta description of the page

I dont want to use meta robot through template as other components are also sharing in same template having some pages as noindex to it

can you help on how to achieve the desired
thanks


Return to “Search Engine Optimization (Joomla! SEO) in Joomla! 3.x”

Who is online

Users browsing this forum: csthomas, gyrocog, Josh Lewis and 6 guests