PDA

View Full Version : custom META tags in header



TARJr
02-06-10, 03:21 PM
Is there a way I can have unique Meta Description and Keywords tags in my Header.tpl file for each page?
So my homepage.tpl will be different from my contact.tpl, etc. and knowledgebase articles can have there own descriptions...

Thanks,

m00
02-06-10, 04:47 PM
You can realize this using the if-statement of smarty:


<META NAME="KEYWORDS" CONTENT="{if $filename eq "index"}keyword,for,index{elseif $filename eq "contact"}keyword,for,contact{/if}" />

jumbiehost
09-29-11, 04:46 PM
THANK YOU! That helps a bunch! Note for everyone else.. Code can be altered and applied to just about anything!

bluebirdnet
01-05-12, 03:10 AM
this is great worked well !

But ideally i would want to use a variable like $metakeyword and put each set of meta keywords in the language file. I would do the same for titles and descriptions.

Does anyone know how to do this? I tried to setup the variable in the php file and then in the header.tpl but its not working. Is there something missing in whmcs ? perhaps a PHP class?

Anyone have any ideas?

thanks

Sitepearl
01-05-12, 03:27 AM
What would be REALLY cool is if Knowledgebase articles had native meta inputs :]

Exactly what page are you trying to put the metatags on? I can probably help you.

bluebirdnet
01-05-12, 02:48 PM
What would be REALLY cool is if Knowledgebase articles had native meta inputs

Agrred! whmcs needs to be extended more to have cms features like that.





Exactly what page are you trying to put the metatags on? I can probably help you.

thanks for offer to help! appreciated.

Manyl pages really, were building the whole site based on the new default theme in V5 and making use of Boostrap css. Dont want to maintain 2 sites and 2 templates anymore (Joomla and whmcs).

So need a way to add unique meta tags per page.

Sitepearl
01-06-12, 05:40 AM
Aha that's exactly what we did with ours - we actually built a WHMCS theme based on our Joomla theme: www.sitepearl.com

If I were to put a meta tag on each custom page (IE: Pages I can edit the PHP source for), I would just create a smarty variable within the PHP file (or a language file), and then access that via {$keywords}, {$description} in the header.tpl file... and maybe add a check to disable it on pages that don't require that meta data (cart.php, etc).

bluebirdnet
01-06-12, 03:04 PM
Hi Sitepearl.

Actually were not building a theme based on Joomla. Were moving the whole site to whmcs. So we dont have to use 2 systems.

Anyhow, yes i tried to do as you say with smarty variable, that would be the easiest way but its not working. I believe something is missing, perhaps a php class or other.

We need to so it exactly like the page titles by adding the variables in the php files and calling them in the header.tpl.

Sitepearl
01-06-12, 03:30 PM
I think you misunderstood - we used to use Joomla/WHMCS, but then we converted our Joomla theme to WHMCS so we didn't have to use two systems.

In your custompage.php file, you should have something like this:
<?php
$smarty->assign("description", "Our company profile");
?>

Then in your header.tpl file, you should be able to do:
{$description}

bluebirdnet
01-06-12, 04:48 PM
I think you misunderstood - we used to use Joomla/WHMCS, but then we converted our Joomla theme to WHMCS so we didn't have to use two systems.

In your custompage.php file, you should have something like this:
<?php
$smarty->assign("description", "Our company profile");
?>

Then in your header.tpl file, you should be able to do:
{$description}

Ok i see, looked at your site looks good all whmcs.

Yes that code looks right, i was reading the docs on smarty and thats what we need is to assign a smarty variable. http://www.smarty.net/docsv2/en/language.variables.tpl



<?php

$smarty = new Smarty();

$smarty->assign('firstname', 'Doug');
$smarty->assign('lastname', 'Evans');
$smarty->assign('meetingPlace', 'New York');

$smarty->display('index.tpl');

?>

thanks! i will work on this tonight and report back.

bluebirdnet
01-07-12, 04:18 PM
I have been unsuccessful with any smarty->assign. Its just not showing up in the page.

Has anyone implemented this? What is in your php file?

bluebirdnet
01-21-12, 02:52 PM
Here is the best way i have found to have custom keywords or descriptions for each page by loading them from the language file!

# This example shows for 2 pages index.php and hosting.php
# In your header tpl add the following,
# This checks to see which php page is loaded and then looks in the language file for the variables i have set.



<meta name="keywords" content="{if $filename eq "index"}{$LANG.keywordsindex}{elseif $filename eq "hosting"}{$LANG.keywordshosting}{/if}" />
<meta name="description" content="{if $filename eq "index"}{$LANG.descriptionindex}{elseif $filename eq "hosting"}{$LANG.descriptionhosting}{/if}" />


# Then in your language file EG: english.php add the following



$_LANG['keywordshosting'] = "keywords, for, hosting";
$_LANG['keywordsindex'] = "Keywords, for, index";
$_LANG['descriptionindex'] = "Description for index.....";
$_LANG['descriptionhosting'] = "Description for hosting....";


Hope this helps you out!

tapnet
04-03-12, 03:33 AM
I have 5 URLs that Google Webmaster tools has detected duplicate title tags and they are all root to the cart.php.

/webhosting/cart.php
/webhosting/cart.php?gid=11
/webhosting/cart.php?gid=12
/webhosting/cart.php?gid=18
/webhosting/cart.php?gid=19


Does anyone know how to get the Title+Meta customized so it doesn't appear as duplicate?