How to add meta description and custom title

gvouliakis 15 Sep, 2012
Hi all from Kos Island - Greece!

As I discovered when assigning a form to a menu item (J! 2.5.7 menu system), CF V 4.0 RC3.5 do not update the html code of the page with browser page title and meta description tag if these are defined in menu item parameters (Page Display Options and Metadata Options).

Here is my workaround to the problem:
1. Wizard Edit: Go to Events > OnLoad Area
2. Add a Custom Code action and configure it placing an action label e.g. 'Set title and meta description to form'
3. Below on code section add the following code:
<?php
$menu = JFactory::getApplication()->getMenu()->getActive();

$doc = JFactory::getDocument();

$doc->setTitle( $menu->params->get('page_title') );
$doc->setDescription( $menu->params->get('menu-meta_description') );
?>

4. Save the Action and the than the form.
Done!!!

Now check the html code of the page. Your Page title and the description meta tag (defined in Menu Item Parameters) is there!!! :wink:

Regards,
George Vouliakis
v-websites.gr
GreyHead 15 Sep, 2012
Hi George,

Thank you.

Bob
pez222 28 Jan, 2013
Is there also a way to add Keywords?

I tried to add this line:

$doc->setKeywords( $menu->params->get('menu-meta_keywords') );

but got only a blank page as result.
GreyHead 28 Jan, 2013
Hi pez222,

There's now a Meta Tager (sic) action in the Utilities Group that will do this for you. Drag a copy into your form On Load event to use it.

Bob
pez222 29 Jan, 2013
Great!

Thanks a lot.
yves-k 22 Aug, 2013
Hello GreyHead
Meta Tager's very nice
But how to set dynamic data in it ?

I try to set meta description from {description} retrieved from the table data but i get
<meta name="description" content="{description}" />...

Is there any way to do it ?

Best regards
GreyHead 22 Aug, 2013
Hi yves-k,

Sorry, I checked the code and it doesn't look as though there is any easy way :-(

It wouldn't be too hard to add that capability though - I'll put it on my to-do list.

Bob
This topic is locked and no more replies can be posted.