fixed problems with meta replacement in js and php
This commit is contained in:
parent
b9416d5b91
commit
88a19b1b98
@ -38,14 +38,16 @@ abstract class api_default extends api_system {
|
|||||||
$meta = $html->getElementsByTagName('meta');//[0]->nodeValue = $state[0]['title'];
|
$meta = $html->getElementsByTagName('meta');//[0]->nodeValue = $state[0]['title'];
|
||||||
foreach($state[0]['meta'] as $metaname=>$metavalue){
|
foreach($state[0]['meta'] as $metaname=>$metavalue){
|
||||||
$found = false;
|
$found = false;
|
||||||
|
$key = explode('_',$metaname);
|
||||||
|
$key = end($key);
|
||||||
for ($i = 0; $i < $meta->length; $i++) {
|
for ($i = 0; $i < $meta->length; $i++) {
|
||||||
if($meta->item($i)->getAttribute('name') == $metaname){
|
if($meta->item($i)->getAttribute('name') == $key){
|
||||||
$found = true;
|
$found = true;
|
||||||
$meta->item($i)->setAttribute('content',$metavalue);}
|
$meta->item($i)->setAttribute('content',$metavalue);}
|
||||||
}
|
}
|
||||||
if(!$found){
|
if(!$found){
|
||||||
$node = $head->appendChild($html->createElement('meta'));
|
$node = $head->appendChild($html->createElement('meta'));
|
||||||
$node->setAttribute($metaname, $metavalue);}
|
$node->setAttribute($key, $metavalue);}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//print_r($state);
|
//print_r($state);
|
||||||
|
|||||||
@ -75,7 +75,13 @@ SYSTEM.prototype.handle_call_pages_page = function (html,entry,id,forced,cached,
|
|||||||
document.title = entry['title'];}
|
document.title = entry['title'];}
|
||||||
//meta
|
//meta
|
||||||
for(var metaname in entry['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
|
//load css
|
||||||
for(var i=0; i < entry['css'].length; i++){
|
for(var i=0; i < entry['css'].length; i++){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user