Pergunta

While it's possible to manually enter the full title of a page displaying a category, how would I go about doing the same for an article page in Joomla 2.5?

The default is to use the article title as the page title, e.g. "How to care for goldfish", with an option to add the site name.

What I want is to have the title as follows: How to care for goldfish | Fish care guides | FishSite.com

The obvious solution would be just to put all that in the title of the article, but then I'd have a problem in the "Latest articles" module, it would become unreadable with all the extra text.

How to solve this? Plugin, coding, or some clever solution? It needs to be more or less automatic though, I can access the Joomla database and change each page title manually but that wouldn't be feasible. If manual text entry is needed, it has to be in Joomla.

Foi útil?

Solução

The plugin system responds to events, so the easiest solution would be a either a Content or System plugin that manipulates the Title by appending the relevant information prior to display.

I think with a content plugin you could use the onContentPrepare event to do all the work.

In rough psuedo code (i.e. this won't run), I would probably end up with something like this:

public function onContentPrepare($context, &$article, &$params, $page = 0)
{
    // Don't run this plugin when the content is being indexed
    if ($context == 'com_finder.indexer') {
        return true;
    }
    // Perform a sanity check to make sure we're on an article layout

    // Build new title
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top