Forums / Setup & design / Page refresh causes custom meta tags, etc. to disappear

Page refresh causes custom meta tags, etc. to disappear

Author Message

Luis Cruz

Friday 09 June 2006 1:09:09 pm

For reference, running ez 3.6.3.

Following the directions in ">this post ( http://ez.no/community/forum/developer/meta_description_tag ), I created for the various objects in the system the following fields:
meta keywords
meta description
html page title

In page_head.tpl, the code checks the current node for these fields; if they are present and not empty strings, it uses those values for the meta data and page title. Otherwise, it uses the default behavior of eZ publish. Complete code of page_head.tpl listed below.

Now, it works fine if I flush the cache and load the page up for the first time. The meta tags and page title display as expected. However, any subsequent page loads cause the page to revert back to the default behavior. Throwing in a debug print-out shows that the first page load treats $node as a complete object; any page load after that shows $node to be empty.

Is this a caching (or lack thereof) issue? I don't have a cache block around the inclusion of the page head in pagelayout.tpl. Can't see anything in the log files indicating an error. Stumped on this one.

Thanks in advance.

page_head.tpl

{*?template charset=utf-8?*}
{default enable_help=true() enable_link=true()}

{let name=Path
     path=$module_result.path
     reverse_path=array()}
  {section show=is_set($module_result.title_path)}
    {set path=$module_result.title_path}
  {/section}
  {section loop=$:path}
    {set reverse_path=$:reverse_path|array_prepend($:item)}
  {/section}
{if and(is_set($node.data_map.html_page_title), ne($node.data_map.html_page_title, ""))}
        {set-block scope=root variable=site_title}{$node.data_map.html_page_title.content}{/set-block}
{else}
        {set-block scope=root variable=site_title}
                {section loop=$Path:path}{$:item.text|wash}{delimiter} / {/delimiter}{/section} - The Quickest Way to Secure Your Network
        {/set-block}
{/if}
{/let}

    <title>{$site_title}</title>

    {section show=and(is_set($#Header:extra_data),is_array($#Header:extra_data))}
      {section name=ExtraData loop=$#Header:extra_data}
      {$:item}
      {/section}
    {/section}
    
    {* check if we need a http-equiv refresh *}
    {section show=$site.redirect}
    <meta http-equiv="Refresh" content="{$site.redirect.timer}; URL={$site.redirect.location}" />
    
    {/section}
    
    {section name=HTTP loop=$site.http_equiv}
    <meta http-equiv="{$HTTP:key|wash}" content="{$HTTP:item|wash}" />
    
    {/section}
    
    {section name=meta loop=$site.meta}
        {switch match=$meta:key|wash()}
        {case match=description}
                {if and(is_set($node.data_map.meta_description), ne($node.data_map.meta_description, ""))}
    <meta name="{$meta:key|wash}" content="{$node.data_map.meta_description.content}" />
                {else}
    <meta name="{$meta:key|wash}" content="{$meta:item|wash}" />
                {/if}
        {/case}
        {case match=keywords}
                {if and(is_set($node.data_map.meta_keywords), ne($node.data_map.meta_keywords, ""))}
    <meta name="{$meta:key|wash}" content="{$node.data_map.meta_keywords.content}" />
                {else}
    <meta name="{$meta:key|wash}" content="{$meta:item|wash}" />
                {/if}
        {/case}
        {case}
    <meta name="{$meta:key|wash}" content="{$meta:item|wash}" />
        {/case}
        {/switch}
    {/section}

    <meta name="MSSmartTagsPreventParsing" content="TRUE" />
    <meta name="generator" content="eZ publish" />

{section show=$enable_link}
    {include uri="design:link.tpl" enable_help=$enable_help enable_link=$enable_link}
{/section}

{/default}

Kristof Coomans

Friday 09 June 2006 11:49:43 pm

Hi Luis

If content view caching is enabled, $node is only available in the pagelayout when the cache isn't available. As soon as content/view can use the cached view, then $node isn't available anymore in the pagelayout.

The node id however is always available (for content/view) in the pagelayout in $module_result.node_id. You can fetch the node then with something like

{let $nd_id=$module_result.node_id
     $nd=fetch('content','node',hash('node_id',$nd_id))}

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Luis Cruz

Monday 12 June 2006 7:25:58 am

That did the trick; one more useful bit of info. to file away.

Thanks, Kristof!

Cheers.

eZ debug

Timing: Jan 18 2025 18:30:02
Script start
Timing: Jan 18 2025 18:30:02
Module start 'content'
Timing: Jan 18 2025 18:30:02
Module end 'content'
Timing: Jan 18 2025 18:30:02
Script end

Main resources:

Total runtime0.1953 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0099 587.9531180.8125
Module start 'content' 0.00990.0049 768.765698.0703
Module end 'content' 0.01480.1804 866.8359533.3750
Script end 0.1952  1,400.2109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00341.7466200.0002
Check MTime0.00130.6856200.0001
Mysql Total
Database connection0.00150.749310.0015
Mysqli_queries0.146675.06231410.0010
Looping result0.00160.82301390.0000
Template Total0.180192.210.1801
Template load0.00080.391810.0008
Template processing0.179391.831710.1793
Override
Cache load0.00050.269510.0005
Sytem overhead
Fetch class attribute can translate value0.00090.484010.0009
XML
Image XML parsing0.00030.141310.0003
General
dbfile0.00291.4857200.0001
String conversion0.00000.003730.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs