Changeset 7624


Ignore:
Timestamp:
Nov 4, 2010, 8:56:36 PM (13 years ago)
Author:
ddtddt
Message:

[extensions] - meta - uses a different tag than the default

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/meta/main.inc.php

    r7518 r7624  
    2929
    3030//Gestion des meta dans le header
    31 add_event_handler('loc_begin_page_header', 'add_meta',56 );
     31add_event_handler('loc_begin_page_header', 'Change_Meta',20 );
     32add_event_handler('loc_end_page_header', 'add_meta',56 );
    3233add_event_handler('loc_begin_page_header', 'add_metacat',61 );
    3334add_event_handler('loc_begin_page_header', 'add_metaimg',71 );
    3435add_event_handler('loc_after_page_header', 'set_meta_back',81);
     36
     37function Change_Meta()
     38 {
     39        global $template;
     40        $template->set_prefilter('header', 'upmata');
     41 }
     42
     43function upmata ($content, &$smarty)
     44 {
     45  $search = '#<meta name="description" content=".*?">#';
     46 
     47  $replacement = '<meta name="description" content="{$PLUG_META}">';
     48
     49  return preg_replace($search, $replacement, $content);
     50 }
     51
     52
    3553
    3654function add_meta()
     
    4159        $meta_infos['related_tags'] = $template->get_template_vars('related_tags');
    4260        $meta_infos['info'] = $template->get_template_vars('INFO_FILE');
    43         $meta_infos['comment'] = $template->get_template_vars('COMMENT_IMG');
     61        $meta_infos['title'] = $template->get_template_vars('PAGE_TITLE');
    4462
    4563        $query = '
     
    7290
    7391        // Description
    74         if (!empty($meta_infos['info']) and !empty($meta['Description']))
    75         {
    76     $template->assign('INFO_FILE', $meta_infos['info'] . ', ' . $meta['Description']);
     92        if (!empty($meta_infos['title']) and !empty($meta_infos['info']) and !empty($meta['Description']))
     93        {
     94    $template->assign('PLUG_META', $meta_infos['title']. ' - ' .$meta_infos['info'] . ', ' . $meta['Description']);
     95        }
     96        elseif (!empty($meta_infos['title']) and !empty($meta['Description']))
     97        {
     98    $template->assign('PLUG_META', $meta_infos['title']. ' - ' .$meta['Description']);
    7799        }
    78100        elseif (!empty($meta['Description']))
    79101        {
    80     $template->assign('INFO_FILE', $meta['Description']);
    81         }
    82 
     102    $template->assign('PLUG_META', $meta['Description']);
     103        }
     104       
    83105        // Robots
    84106        if (!empty($meta['robots']))
     
    95117  $meta_infos['related_tags'] = $template->get_template_vars('related_tags');
    96118  $meta_infos['info'] = $template->get_template_vars('INFO_FILE');
    97   $meta_infos['comment'] = $template->get_template_vars('COMMENT_IMG');
    98  
    99119
    100120        //meta categories
     
    122142    if (!empty($row['metadescat']))
    123143    {
    124       $template->assign('COMMENT_IMG', $row['metadescat']);
    125           $template->clear_assign('INFO_FILE');
     144      $template->assign('PLUG_META', $row['metadescat']);
    126145    }
    127146  }
     
    135154  $meta_infos['related_tags'] = $template->get_template_vars('related_tags');
    136155  $meta_infos['info'] = $template->get_template_vars('INFO_FILE');
    137   $meta_infos['comment'] = $template->get_template_vars('COMMENT_IMG');
     156
    138157  //meta images
    139158  if ( !empty($page['image_id']) )   
     
    160179    if (!empty($row['metadesimg']))
    161180    {
    162       $template->assign('COMMENT_IMG', $row['metadesimg']);
    163           $template->clear_assign('INFO_FILE');
     181      $template->assign('PLUG_META', $row['metadesimg']);
    164182    }
    165183       
     
    178196    'related_tags' => $meta_infos['related_tags'],
    179197    'INFO_FILE'    => $meta_infos['info'],
    180         'COMMENT_IMG'  => $meta_infos['comment']
    181198    )
    182199  );
Note: See TracChangeset for help on using the changeset viewer.