Differences

This shows you the differences between two versions of the page.

english:phpwcms_replacer_rts:integrated-tags:meta-tag [2009/08/26 21:40]
Knut Heermann (flip-flop) created
english:phpwcms_replacer_rts:integrated-tags:meta-tag [2018/06/03 18:09] (current)
Line 3: Line 3:
====== Meta-Tag in frontend_render ====== ====== Meta-Tag in frontend_render ======
-Meta tags can be set also at run-time by php instruction in ..../frontend_render/ -folder.+Meta Tags can be injected at runtime via PHP (placed within ..../frontend_render/ folder).
 +This is made possible by using the code ##set_meta($name='', $content='', $http_equiv=FALSE)##.
-You can do it using the function ##set_meta($name='', $content='', $http_equiv=FALSE)##.+Available since v1.4.x r314 \\ 
 +Google code: [[http://code.google.com/p/phpwcms/source/detail?r=314|Render <meta> description and <meta> keyword]] 
 +<code>New function to set <meta> tags set_meta($name, $content[, bool $http_equiv=FALSE])  
 +- if $http_equiv=FALSE then <meta name="$name".../>, $http_equiv=TRUE then <meta http-equiv="$name".../> 
 +New frontend_render sample scripts to generate or enhance meta tags and script to render custom menu  
 +(link sitemap block as often used in footer of pages) 
 +</code>
 +\\
 +
 +==== Example 1: ====
Forum: [[http://forum.phpwcms.org/viewtopic.php?p=119381#p119381]] [DE] Forum: [[http://forum.phpwcms.org/viewtopic.php?p=119381#p119381]] [DE]
Line 16: Line 26:
set_meta('copyright', '2009 OG');     //<meta name="copyright" content="2009 OG" /> set_meta('copyright', '2009 OG');     //<meta name="copyright" content="2009 OG" />
set_meta('imagetoolbar', 'no', true); //<meta http-equiv="imagetoolbar" content="no" /> set_meta('imagetoolbar', 'no', true); //<meta http-equiv="imagetoolbar" content="no" />
 +set_meta('description', 'This is my description for just a test');
 +set_meta('robots', 'index,follow');
 +set_meta('Content-Language', 'en', TRUE);
 +</code>
 +\\
 +Please have a lool too into the file **template/inc_script/frontend_render/disabled/keywords.php**.
 +\\
 +
 +==== Example 2: ====
 +
 +
 +Forum: [[http://forum.phpwcms.org/viewtopic.php?p=138902#p138902]] [DE]
 +
 +<code PHP>
 +set_meta('date', date('Y-m-d'));
 +// Types:
 +// - name (default)
 +// - prop/property
 +// - itemprop
 +// - http-equiv
 +// - or whatever you like as $type
 +set_meta('refresh', '30', 'http-equiv');
</code> </code>
 +
 +\\
 +Are the meta tags already exist, they are entered with ##set_meta (...## a second time. If this is not desired, one of these methods can be used -> [[english/technics/title-and-meta-tags]].
 +
 +\\
 +==== Replacer example: ====
 + 
 +  * Folder: template/inc_script/frontend_render/*
 +  * File: rt_set_meta.php
 +
 +<code php |h rt_set_meta.php |h >
 +<?php
 +/*
 + **************************************************************************
 + * Meta TAGs set into <head> Text </head> of the site
 + *
 + * File: template/inc_script/frontend_render/rt_set_meta.php
 + *
 + * 31.11.2012 KH: heermann@planmatrix.de
 + * ************************************************************************/
 + 
 +// ------------------------------------------------------------------------
 +// obligate check for phpwcms constants
 +if (!defined('PHPWCMS_ROOT')) {
 +   die("You Cannot Access This Script Directly, Have a Nice Day."); }
 +// ------------------------------------------------------------------------
 +
 +
 +// {SET_META_} replacement
 +// =======================================================
 +if( ! (strpos($content["all"],'{SET_META_')===false)) {
 +
 + // {SET_META_COPYRIGHT}  
 + // -----------------------------------------------------
 + if( ! (strpos($content["all"],'{SET_META_COPYRIGHT}')===false)) {
 + set_meta('copyright', date('Y').' My Name'); // Set META-Data
 +// $content['all'] = str_replace('{SET_META_COPYRIGHT}', '', $content['all']); // Delete TAG
 + }
 + // {SET_META_REVISIT-AFTER}  
 + // -----------------------------------------------------
 + if( ! (strpos($content["all"],'{SET_META_REVISIT-AFTER}')===false)) {
 + set_meta('revisit-after', '2 days'); // Set META-Data
 +// $content['all'] = str_replace('{SET_META_REVISIT-AFTER}', '', $content['all']); // Delete TAG
 + }
 + // And so on ......
 + // -----------------------------------------------------
 +
 +
 +
 + // Delete all TAGs
 + // -----------------------------------------------------
 + $content["all"] = preg_replace('/{SET_META_(.*?)}/s', '', $content["all"]);
 +
 +}
 +
 +?>
 +</code>
 +
 +
 +\\
 +Have a look too: [[english/technics/title-and-meta-tags]]
 +
 +\\
english/phpwcms_replacer_rts/integrated-tags/meta-tag.1251315631.txt.gz · Last modified: 2018/06/03 18:08 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0