Fork me on GitHub

Meta keywords and title different for all the pages...  Bottom

  • Hi there,

    I would like to know has anybody being able to do this.

    Each page has its own meta keywords and title.

    I have searched lot of information about it but no luck.

    any help or pointer with this would be greatly appreciated.

    Manoj
  • I found the title part in header.php:

    global $info, $hometext;
    echo "\n";
    if (pnConfigGetVar('dyn_keywords') == 1) {
    $htmlless = check_html($info['maintext'], $strip ='nohtml');
    $symbolLess = trim(ereg_replace('("|\?|!|:|\.|\(|\)|;|\\\\)+', ' ', $htmlless));
    $keywords = ereg_replace('( |'.CHR(10).'|'.CHR(13).')+', ',', $symbolLess);
    $metatags = ereg_replace(",+", ",",$keywords);
    echo "\n";
    } else {
    echo "\n";
    }
    } else {
    /**
    * all other page output
    */
    echo '\n";
    echo '\n";



    and changed this part:

    echo '\n";

    to

    echo '\n";

    I also had to change global $info, $hometext; to global $info, $hometext, $extratitle;

    Then I went into each page that I wanted to have a different title first and added:

    $extratitle="New Title";

    The value has to be assigned before the header function is called and if the value isn't assigned, like say you left it out on a certain page, it doesn't do anything since the value is empty so it didn't hurt any to put it there.

    You can also set up a MySQL Database query to get a title out of the database but that's kind of useless as there aren't that many pages that are going to need this since the articles page has the unique titles for each article using the article title.

    Are you wanting to change the title that appears on the article page?
  • hi reallynicejerk,

    thanks indeed for your nice suggestion. I got your concept of putting $title. But how do i put it on pages and modules.

    I want the Title o the article to be title of the page. I believe its difficult to do bcos headers are written before the page and content is even drawn.

    so what do u think is solution or workaround for this.

    Manoj
  • what version postnuke are you running?

    On all the versions that I've seen the title of the article is the title on the page when you read the article... however I haven't seen very many different versions.

    as for putting it into a module try going to the module's different pages and setting the variable the way I showed:

    $extratitle='Your extra title here in between the apostrophes, don\'t forget backslashes for apostrophes and to use '.$this.' setup for '.$variables.' because PHP won\'t search for '.$variables.' when they are within apostrophes (which makes apostrophes faster to parse than quotation marks).';

    or reallistically:

    $extratitle='Welcome to my website!';

    anyway you can also put them in the modules.php file like this:

    if ($op=="modload"){
    if($name=="Members_List"){
    $extratitle='Welcome to my member\'s list page!';
    }
    if($name=="My_custom_modulet"){
    $extratitle='This page is a custom module that I created myself!!!';
    }
    }

    and so on

This list is based on users active over the last 60 minutes.