Jump to content

custom META tags in header


TARJr

Recommended Posts

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,

Link to comment
Share on other sites

  • 1 year later...
  • 3 months later...

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Aha that's exactly what we did with ours - we actually built a WHMCS theme based on our Joomla theme: http://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).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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!

Edited by bluebirdnet
forgot something
Link to comment
Share on other sites

  • 2 months later...

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?

Link to comment
Share on other sites

  • 8 years later...
On 4/3/2012 at 5:33 AM, tapnet said:

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?

Any solution for this issue?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated