Jump to content

Insert into title with clean querystring


kurt.santo

Recommended Posts

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

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

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

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

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...