Forums / Developer / Implementing MetaTags in EZ (version 4.1.0)

Implementing MetaTags in EZ (version 4.1.0)

Author Message

Akhilesh Singh

Thursday 18 June 2009 12:06:31 am

Hey guys I am really new to EZ publish (using version 4.1.0).
I have searched many forums but i think others are stuck in some place between implementing meta tags.
But I don't know how to start implementing it. what i know is that in site.ini file we can change MetaDataArray which will reflect in all of my pages
but I want different description and keyword for all my pages . Can any one help me here and guide me the steps for implementing meta.
Please help me guys.

Thank you
Akhi

Gaetano Giunta

Thursday 18 June 2009 12:48:50 am

If you want to implement meta-tags at the object level, one solution is to do it via usage of the persistent_variable.
It is a long process, but it has the advantage not to rely on ini system:
- add to all your content classes some attributes, of type text line, such as html_meta_description, html_meta_keywords etc (you can add names of etxra css or js file too)
- create an override template for node/view/full.tpl where you test if those members are set in $node.data_map and if they are you set them into the variable $persistent_variable, making it a hash. Use this override for all content classes
- in the the pagelayout.tpl template, you can use $content_info.persistent_variable to retrieve the values that have been set by the current node and create the html header as needed

Principal Consultant International Business
Member of the Community Project Board

Jean-Luc Nguyen

Thursday 18 June 2009 12:54:08 am

Hi,

For a site I did, I created a class named "Meta", with attributes "Title", "Keywords" and "Description". So when I create a new "Meta" object under an object, this one has its own Meta. If it does not have a Meta object under, it has the Meta object created under the root node (node_id=2).

{* Is there a Meta object under my node? *}
{def $meta = ''}
{if is_set( $module_result.node_id )}
	{if fetch( 'content', 'list_count', hash(	'parent_node_id', $module_result.node_id,
												'limit', 1,
												'class_filter_type', 'include',
												'class_filter_array', array( 'meta' ) ) ) }
		{set $meta = fetch( 'content', 'list', hash(	'parent_node_id', $module_result.node_id,
														'limit', 1,
														'class_filter_type', 'include',
														'class_filter_array', array( 'meta' ) ) ).0}
	{else}
		{* Else we display the Meta under the root node *}
		{set $meta = fetch( 'content', 'list', hash(	'parent_node_id', 2,
														'limit', 1,
														'class_filter_type', 'include',
														'class_filter_array', array( 'meta' ) ) ).0}										    
	{/if}				
	<meta name="keywords" lang="en" content="{if $meta.data_map.keywords.has_content}{$meta.data_map.keywords.content|wash}{/if}" /> 
	<meta name="description" content="{if $meta.data_map.description.has_content}{$meta.data_map.description.content|wash}{/if}" />
{/if}
{undef $meta}

http://www.acidre.com

Frédéric DAVID

Thursday 18 June 2009 2:17:24 am

Hi

two extensions exist for implementing meta tags in eZ.

http://projects.ez.no/xrowmetadata
http://projects.ez.no/fezmetadata

I think the two extensions are compatible with eZ 4.1, but i'm not sure.

Blog : http://www.frefred.fr/blog/ez-publish
feZ Meta Data : http://projects.ez.no/fezmetadata

Akhilesh Singh

Thursday 18 June 2009 5:10:39 am

Thanks All for replying,

1)Jean-Luc Nguyen,
Thanks,
have tried this by creating class using text-line attributes but it give me object meta and shows text line boxs(like text box),
and its reflect in content part and not in header section.

Can u please give in more details about
"it has the Meta object created under the root node (node_id=2)". and what type of attribute to use while adding (Title,Keywords,..)

and please provide more details

2)Frédéric DAVID
Thanks,
have download and followed all the steps.
but only final step box shown in screenshot never displays in page setting in admin interface. rest all steps work

and please provide more details

3)Gaetano Giunta
Thanks,
m now looking at this to implemnt

Jean-Luc Nguyen

Thursday 18 June 2009 5:47:30 am

Hello,

the indented code:

{* Is there a Meta object under my node? *}
{def $meta = ''}
{if is_set( $module_result.node_id )}
	{if fetch( 'content', 'list_count', hash(   'parent_node_id', $module_result.node_id,
												'limit', 1,
												'class_filter_type', 'include',
												'class_filter_array', array( 'meta' ) ) ) }
		{set $meta = fetch( 'content', 'list', hash(    'parent_node_id', $module_result.node_id,
														'limit', 1,
														'class_filter_type', 'include',
														'class_filter_array', array( 'meta' ) ) ).0}
	{else}
		{* Else we display the Meta under the root node *}
		{set $meta = fetch( 'content', 'list', hash(    'parent_node_id', 2,
														'limit', 1,
														'class_filter_type', 'include',
														'class_filter_array', array( 'meta' ) ) ).0}                                                                                
	{/if}                           
	
	<meta name="keywords" lang="en" content="{if $meta.data_map.keywords.has_content}{$meta.data_map.keywords.content|wash}{/if}" /> 
	<meta name="description" content="{if $meta.data_map.description.has_content}{$meta.data_map.description.content|wash}{/if}" />

{/if}
{undef $meta}

This has to be between the <head></head> tags.
The class I created is:
- class name: meta
- attribute: title (text line)
- attribute: keywords (text line)
- attribute: description (text line)

This is for keywords and description metatags.
You have to create a new node "meta" under the root node on the backend. It will be the fallback for each node that has no "meta" node under it.

ROOT
-- node 1
---- node meta 1
-- node 2
-- node 3
---- node meta 3
-- node meta root

node 1 will display node meta 1
node 3 will display node meta 3
root node and node 2 will display node meta root, as node 2 does not have any "meta" node under it.

I hop this will help and that you understand.

http://www.acidre.com

Akhilesh Singh

Monday 22 June 2009 5:47:05 am

hi Jean-Luc Nguyen..
sorry for delay in reply ...
I tried your solution and have added that code in head section of "pagelayout.tpl"
Now I am getting custom description and keywords on the pages but issue is that
The default Meta description in EZ is also there in my pages
(Do i need to Delete original Meta Info .?? or any thing else please suggest)
and whenever i am adding the Meta object in my pages
it is also added as an hyperlink in my page.(it is happening for all my objects)
And reset of the pages on which i haven't added that Meta object that also displays Meta tags but has no content.(which i think should not happen..?)
please guide me if i am missing something and till know your suggestions have been really helpful to me thanx for that.

<b>My Meta Class DESC:</b>
Name: Meta
Identifier: meta
Object name pattern: <form_name>
URL alias name pattern:
Container: Yes
Default object availability: Not available
Default sorting of children: Depth / Ascending
Object count: 4

Attributes
1. Form name [Text line] (id:384)
Name:Form name
Identifier:form_name
Flags:Is not required /Is searchable/ Does not collect information /Translation is enabled

2. Title [Text line] (id:385)
Name:Title
Identifier:title
Flags:Is required /Is not searchable /Collects information/Translation is enabled

3. Keywords [Text line] (id:386)
Name:Keywords
Identifier:keywords
Flags:Is required / Is not searchable / Collects information / Translation is enabled

4. Description [Text line] (id:387)
Name:Description
Identifier:description
Flags:Is required / Is not searchable / Collects information / Translation is enabled

Thank u all ,
Akhi

 

Jean-Luc Nguyen

Monday 22 June 2009 6:01:54 am

Hi,

Your class attributes should not collect information, and the form_name attribute is not necessary.

If I understand you, you don't want a default meta right? In that case, you should delete the code under the else condition.

http://www.acidre.com

Akhilesh Singh

Wednesday 24 June 2009 12:22:07 am

Hi Jean-Luc Nguyen..

Thanks I have done what u suggested and was successful in doing that.
1.But Default Meta Tags are still on my page Like below:
<meta name="description" content="Content Management System" />
<meta name="keywords" content="cms, publish, e-commerce, content management, development framework" />
2.We have created attributes for Title tag but in code you have not mentioned any thing about title tag.
can u please suggest me for custom title of the page also. Thanks also...

Akhi

Jean-Luc Nguyen

Wednesday 24 June 2009 12:36:01 am

Hello,

1/ Do you have cache on your template? Try to clear it.
2/ Title tag is only here for backend use.

Please contact me, GTalk: jeanluc.nguyen at gmail.com in order to fix that thing.

http://www.acidre.com

Akhilesh Singh

Wednesday 24 June 2009 2:56:50 am

HI Jean-Luc Nguyen

Thank A lot now i am completely done with custom Meta and Title tags and its truly because of your help. you are really doing a great job. keep it on your good work thank you.

Akhi