fixed problems with meta replacement in js and php

This commit is contained in:
Ulf Gebhardt 2016-05-28 01:42:17 +02:00
parent b9416d5b91
commit 88a19b1b98
2 changed files with 11 additions and 3 deletions

View File

@ -38,14 +38,16 @@ abstract class api_default extends api_system {
$meta = $html->getElementsByTagName('meta');//[0]->nodeValue = $state[0]['title'];
foreach($state[0]['meta'] as $metaname=>$metavalue){
$found = false;
$key = explode('_',$metaname);
$key = end($key);
for ($i = 0; $i < $meta->length; $i++) {
if($meta->item($i)->getAttribute('name') == $metaname){
if($meta->item($i)->getAttribute('name') == $key){
$found = true;
$meta->item($i)->setAttribute('content',$metavalue);}
}
if(!$found){
$node = $head->appendChild($html->createElement('meta'));
$node->setAttribute($metaname, $metavalue);}
$node->setAttribute($key, $metavalue);}
}
}
//print_r($state);

View File

@ -75,7 +75,13 @@ SYSTEM.prototype.handle_call_pages_page = function (html,entry,id,forced,cached,
document.title = entry['title'];}
//meta
for(var metaname in entry['meta']) {
$('meta[name='+metaname+']').attr('content', entry['meta'][metaname]);
var key = metaname.split('_');
key = key[key.length-1];
if($('meta[name='+key+']').length > 0){
$('meta[name='+key+']').attr('content',entry['meta'][metaname]);
} else {
$('head').append('<meta name="'+key+'" content="'+entry['meta'][metaname]+'">');
}
}
//load css
for(var i=0; i < entry['css'].length; i++){