Hello, dear users. The fact is that I need to register meta tags to certain pages in Drupal, but I only have access to FTP, so I have such a question. It is possible to prescribe a condition in the template code via php: something like if current page = "our page", then its title and description is equal to that. About the picture something like that

  • Sure you may. Similarly. - nick_n_a February
  • I would like to know the exact command, because the one I ordered does not help - nstgb

3 answers 3

Take out all the conditions in the function:

function md_title(){ if(is_category() || is_tag()){single_cat_title();} elseif(is_month()){the_time('Архив за F, Y года');} elseif(is_day()){the_time('Архив за j FY года');} elseif(is_year()){the_time('Архив за Y год');} md_paged(); } 

And then output the result of the function:

 <meta name="description" content="<?php md_title()?>"> 
  • Could you please give an example of how to register a title and dexription in this situation, say for the site vk.com - nstgb

You need this module:

https://www.drupal.org/project/metatag

It is possible to prescribe meta tags in the general site, in particular, individual pages or groups of pages.

    I recommend to look at the answers @Crantisz and @Vadizar - their solution is much better and more intelligent.

    If for some reason it does not suit you, then here is a simple code that will help you do what you want:

     $data = array( 'index.php' => ' <title>Главная</title> <meta name="description" content="главная страница....">', 'test.php' => ' <title>Страница</title> <meta name="description" content="какая-то страница">' ); ?> <html> <head> <?php print $data[basename(__FILE__)]; ?> </head> <body> </body> </html>