kurt.santo Posted November 20, 2007 Share Posted November 20, 2007 Is it possible to insert the content of the title tag without using a querystring? Would love to keep the urls for my English version "clean" as such...Kurt Link to comment Share on other sites More sharing options...
Ingolme Posted November 20, 2007 Share Posted November 20, 2007 I'm not exactly sure if this is what you're asking: <?php// Assuming the "get" variable for language is called "lang"switch($_GET['lang']) {case "en":echo "English title";break;case "fr":echo "French title";break;case "es":echo "Spanish title";break;//...//continue with each language//...} Link to comment Share on other sites More sharing options...
kurt.santo Posted November 20, 2007 Author Share Posted November 20, 2007 I'm not exactly sure if this is what you're asking:<?php// Assuming the "get" variable for language is called "lang"switch($_GET['lang']) {case "en":echo "English title";break;case "fr":echo "French title";break;case "es":echo "Spanish title";break;//...//continue with each language//...} What would I do with my standard language (where I would like to keep querystring clean)? I use at top of file "$def_lang = 'en';".Kurt Link to comment Share on other sites More sharing options...
Ingolme Posted November 20, 2007 Share Posted November 20, 2007 Just use switch() with the variable that defines the language of the page:switch($def_lang)And put the PHP within the title tags:<html><head><title><?phpswitch($def_lang) {// ... ...}?></title>...... Link to comment Share on other sites More sharing options...
justsomeguy Posted November 20, 2007 Share Posted November 20, 2007 Can't you just define the title variable in the include file that you're using to store the other language-specific text? Link to comment Share on other sites More sharing options...
kurt.santo Posted November 21, 2007 Author Share Posted November 21, 2007 Can't you just define the title variable in the include file that you're using to store the other language-specific text?I would not have thought so as they are html pages and they are just a tiny html bit of the overall page as such. I would prefer to do so, but how?Kurt Link to comment Share on other sites More sharing options...
justsomeguy Posted November 21, 2007 Share Posted November 21, 2007 Have a PHP file in the language folder that has variable definitions for things like this. Or, include the variable definition in the per-page content file and output that on the page. I'm not sure how you have the language files structured, but you can put a variable definition somewhere. Link to comment Share on other sites More sharing options...
kurt.santo Posted November 21, 2007 Author Share Posted November 21, 2007 Have a PHP file in the language folder that has variable definitions for things like this. Or, include the variable definition in the per-page content file and output that on the page. I'm not sure how you have the language files structured, but you can put a variable definition somewhere.I have structured my files as you suggested in an earlier post. All my php files are in my web root folder and then I have an "en" folder with the english language files stored in nav for all navigation bars and in content for all content files. I did the same in a folder called "de" for the German language files...Where could I put it in the per page content files? Currently they hold data as:<h1>About</h1><p>kurt is a funny man and he does not have a clue about PHP...</p><p>That is why is asking many stupid questions, so hopefully he will mature into a decent php coder at some stage;-)</p> Would I put this before the html? Which option would you prefer yourself? It might be an idea to keep in all in one file (for both languages) for easier maintenance?Kurt Link to comment Share on other sites More sharing options...
justsomeguy Posted November 26, 2007 Share Posted November 26, 2007 You can either have a new file where you keep variable definitions that the other files use, or you will need to change your content files to contain variables that you can print instead of HTML that just gets echoed out as soon as you include the file. If the title changes per page depending on the content, then you might want to store the title in the content file. You can do something like this: <?php$page_title = "Title";$page_content = <<<EOT<h1>About</h1><p>kurt is a funny man and he does not have a clue about PHP...</p><p>That is why is asking many stupid questions, so hopefully he will mature into a decent php coder at some stage;-)</p>EOT;?> Then you include that file and echo $page_title and $page_content where you want them to go. Link to comment Share on other sites More sharing options...
kurt.santo Posted November 26, 2007 Author Share Posted November 26, 2007 You can either have a new file where you keep variable definitions that the other files use, or you will need to change your content files to contain variables that you can print instead of HTML that just gets echoed out as soon as you include the file. If the title changes per page depending on the content, then you might want to store the title in the content file. You can do something like this:<?php$page_title = "Title";$page_content = <<<EOT<h1>About</h1><p>kurt is a funny man and he does not have a clue about PHP...</p><p>That is why is asking many stupid questions, so hopefully he will mature into a decent php coder at some stage;-)</p>EOT;?> Then you include that file and echo $page_title and $page_content where you want them to go. Will have a go and see how it works. Why is "<<<EOT" having three arrors? What does this stand for?Kurt Link to comment Share on other sites More sharing options...
justsomeguy Posted November 26, 2007 Share Posted November 26, 2007 http://www.php.net/manual/en/language.type....syntax.heredoc Link to comment Share on other sites More sharing options...
kurt.santo Posted November 27, 2007 Author Share Posted November 27, 2007 http://www.php.net/manual/en/language.type....syntax.heredocCheers,had a read through and will try the suggested solution...Kurtjustsomeguy,changed my site to use includes files as suggested and am very grateful I do not need to use my querystring to get the title information. Great help!Kurt Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.