Meta description & Keywords

Author Message

Alejandro Dominguez

Wednesday 09 February 2011 4:55:30 am

I'm using eZ 4.4 with eZFlow. I have created a class for news where I had two atributtes for the metatags, description & keywords. I don't know what I should do to display this metatags in the header.

I thought a template override for page_head.tpl can be the right idea. What do you think?

cheers,

Alejandro

Guillaume Kulakowski

Wednesday 09 February 2011 6:28:31 am

"

 

I thought a template override for page_head.tpl can be the right idea. What do you think?

"

Use template fallback : http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Concepts-and-basics/Designs/Design-combinations/%28language%29/eng-GB

My blog : http://www.llaumgui.com (not in eZ Publish ;-))
eZC on RHEL : http://blog.famillecollet.com/pages/Config-en
eZC on Fedora : just "yum install php-channel-ezc"

Gaetano Giunta

Wednesday 09 February 2011 12:46:34 pm

As Guillaume said, a template fallback is enough, in the sense that your new template will be used in every case. Teplate overrides are only used when specific conditions match.

In your new page_head.tpl you can fetch current object and get the attributes for meta tags, but that will be expensive in sql queries, ram and cpu.

So you should add a cache-block around that part (quick and dirty fix), or, better, rely on usage of the persistent variable (look up in the forums and tutorials on how to do it)

Principal Consultant International Business
Member of the Community Project Board

Alejandro Dominguez

Thursday 10 February 2011 2:45:33 am

Hello guys,

thanks for your quick answer. I solve this problem with an override of pagelayout.tpl

This is my code. It can be helpfull for other users

{def $node_id=$module_result.node_id
$node=fetch( 'content', 'node', hash('node_id', $node_id ) )}
<meta name="keywords" content="{attribute_view_gui attribute=$node.object.data_map.meta_keywords}" />
<meta name="description" content="{attribute_view_gui attribute=$node.object.data_map.meta_description}" />

Another question: I got this output in both metatags

Theres is an enter between " and key1. any ideas of how I can avoid this? I think this must be easy but I can't find the solution.

<meta name="keywords" content="

key1,key2,key3" />

Franck Magnan

Thursday 10 February 2011 3:30:58 am

Hello Alejandro,

when you use the "attribute_view_gui" operator, eZ Publish call most suitable template file to display your attribute. If you want to know which template file is loaded for meta_keywords datatype, you can enable output debug and template output for your siteaccess. Then, you will see which template file is loaded in the source code of your page. This give you a lead to find why you have a line return in your code.

You can also decide to not use attribute_view_gui operator and modify your code to get this :

{if $node.object.data_map.meta_keywords.has_content}
    <meta name="keywords" content="{$node.object.data_map.meta_keywords.content|wash()}" />
{/if}
{if $node.object.data_map.meta_description.has_content}
    <meta name="description" content="{$node.object.data_map.meta_description.content|wash()}" />
{/if}

hope this help

--
Developer at Open Wide

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 04:21:41
Script start
Timing: Jan 18 2025 04:21:41
Module start 'layout'
Timing: Jan 18 2025 04:21:41
Module start 'content'
Timing: Jan 18 2025 04:21:42
Module end 'content'
Timing: Jan 18 2025 04:21:42
Script end

Main resources:

Total runtime0.8971 sec
Peak memory usage4,096.0000 KB
Database Queries67

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 589.0469152.6250
Module start 'layout' 0.00710.0030 741.671939.4531
Module start 'content' 0.01010.8854 781.1250659.5547
Module end 'content' 0.89560.0015 1,440.679716.1641
Script end 0.8971  1,456.8438 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.3950160.0002
Check MTime0.00140.1575160.0001
Mysql Total
Database connection0.00110.117410.0011
Mysqli_queries0.825592.0212670.0123
Looping result0.00090.0959650.0000
Template Total0.861796.120.4309
Template load0.00200.228520.0010
Template processing0.859795.825220.4298
Template load and register function0.00010.013810.0001
states
state_id_array0.00120.138810.0012
state_identifier_array0.00450.499920.0022
Override
Cache load0.00180.2031390.0000
Sytem overhead
Fetch class attribute can translate value0.00070.077940.0002
Fetch class attribute name0.00230.251890.0003
XML
Image XML parsing0.00250.278540.0006
class_abstraction
Instantiating content class attribute0.00000.0019100.0000
General
dbfile0.00170.1882340.0000
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs