Forums / Setup & design / Meta description & Keywords

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

eZ debug

Timing: Jan 18 2025 00:58:08
Script start
Timing: Jan 18 2025 00:58:08
Module start 'content'
Timing: Jan 18 2025 00:58:10
Module end 'content'
Timing: Jan 18 2025 00:58:10
Script end

Main resources:

Total runtime1.6009 sec
Peak memory usage4,096.0000 KB
Database Queries204

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 588.8281180.8438
Module start 'content' 0.00691.4527 769.6719664.6328
Module end 'content' 1.45960.1412 1,434.3047341.0938
Script end 1.6008  1,775.3984 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.2303210.0002
Check MTime0.00150.0918210.0001
Mysql Total
Database connection0.00100.065510.0010
Mysqli_queries1.507094.13672040.0074
Looping result0.00220.13632020.0000
Template Total1.569898.120.7849
Template load0.00190.120920.0010
Template processing1.567897.936220.7839
Template load and register function0.00020.012110.0002
states
state_id_array0.00080.049810.0008
state_identifier_array0.00140.089920.0007
Override
Cache load0.00170.1069390.0000
Sytem overhead
Fetch class attribute can translate value0.00230.143150.0005
Fetch class attribute name0.00120.076890.0001
XML
Image XML parsing0.00530.330650.0011
class_abstraction
Instantiating content class attribute0.00000.0011100.0000
General
dbfile0.01460.9149450.0003
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 8

Time used to render debug report: 0.0002 secs