2

I'd like to add the following to the meta tags for a single page on my D7 site:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

Taken from here

However, when I try to use metatags_quick to accomplish this, it names all my metatags as

<meta name="Cache-Control" content="no-cache, no store, must revalidate">

with the "name=" attributes rather than "http-equiv". How can add these tags?

3

I want to say that, in some cases, you can add by template way your meta tags to your specific page.

you can locate html.php.tpl in modules > system file. copy and paste it inside your template directory. then add your meta tags using some php code to show these tags only in that specific page:

  <?php
  if(isset($_GET['q'])){
      $path = $_GET['q'];
      if(preg_match('/test/', $path)){
      ?>
        <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
        <meta http-equiv="Pragma" content="no-cache">
        <meta http-equiv="Expires" content="0">
      <?  
      } 
  };
  ?>

(you can add this snippet before, for example, the <title> tag line)

remember that if you need your meta in more pages, you can replace the pattern of preg_match() php function (in this example is /test/) for several pages (for example /(test|another_test_page|another)/ )

Update: if you do not see changes, is very important clear cache to see changes.

Update2 drupal_get_path_alias() could be an useful function to get the current alias: Given an internal Drupal path, return the alias.

  • I copied this into the html.tpl.php (it's that way, right? You wrote html.php.tpl) just above the <title><?php print $head_title; ?></title> line, and changed '/test/' to 'Page-Name', since I'm looking to do this on "www.mysite.com/Page-Name". I moved this into my active template directory. It did not seem to have any effect, and isn't visible when I view source on that page. Any suggestions on what I've done wrong? – Mittenchops Oct 3 '11 at 16:42
  • hello @Mittenchops. change Page-Name by /Page-Name/ (please do not remove // characters, are important delimiters of string, and not is related with paths). Also remember that you can debug each php line, for example, see with echo $_GET['q']; if is getting the correct string. also review if changing delimiters in preg_match() function help (change /Page-Name/ for #Page-Name#) one note: please remember do not change the html.php.tpl in modules > system. you must change a copy used inside your template directory. – cigotete Oct 3 '11 at 18:46
  • That's really strange---I added the slashes back, and noticed that even when I add if(true){ ... as the conditional statement, it still isn't displaying. I am editing the copy in my theme's template directory, rather than in modules > system, so I wonder what the issue is. The place I need to copy the file is in my theme's template directory, right? – Mittenchops Oct 3 '11 at 19:30
  • 1
    I'm dumb---had to clear cache. Your solution worked perfectly. Thanks. – Mittenchops Oct 3 '11 at 19:52
  • you have reason, clear cache! I will add this in the answer! Thanks to you. – cigotete Oct 4 '11 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.