Meta tag code

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
grgalex
Ensign (ENS)
Ensign (ENS)
Posts: 15
Joined: Thu Jun 21, 2012 1:34 pm

Meta tag code

Post by grgalex » Fri Mar 27, 2015 7:03 pm

Does anyone know if there is an easy way of making category titles populate the meta description and meta keyword fields automatically.
Thanks in advanced :D

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Meta tag code

Post by Katie » Sun Mar 29, 2015 9:05 am

Can you be more specific? What version of AbleCommerce are you using?

There should be a title field available for categories. I believe the feature was added to Gold R6 in Sept. 2013.

I'm not sure it would be advisable to populate this with your meta description and/or keywords since the title has it's own requirements, and it is different than meta info.

There is lots of great info that you can find on SEO. Here is one page that has some basic requirements for the Title field.

http://searchenginewatch.com/sew/how-to ... lden-rules#
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

grgalex
Ensign (ENS)
Ensign (ENS)
Posts: 15
Joined: Thu Jun 21, 2012 1:34 pm

Re: Meta tag code

Post by grgalex » Tue Mar 31, 2015 9:11 am

Running Gold R10 Responsive. When working with categories if you leave the page title field empty it will automatically populate the meta title by using the name. Obviously there is code for this to be done and my question is if there is already code that auto populates the meta title from the page name should it not be easy to add some code to populate the meta description and meta keywords from the page name as well. I have over 20000 categories and cannot imagine doing each one individually. As a matter of fact I had paid for a program several years ago for ac7 that did just that but does not work with gold. If not, could you point me in the direction of where the code is that currently does the above mentioned function.
Thanks :D

rmaweb
Commander (CMDR)
Commander (CMDR)
Posts: 118
Joined: Fri Sep 10, 2010 9:41 am

Re: Meta tag code

Post by rmaweb » Tue Mar 31, 2015 9:20 am

Hello grgalex,

If you go to Website/App_Code/PageHelper.cs and go to the BindMetaTags() function, you should be able to find what you need to get started.
Ryan A.
Scott's Bait and Tackle
http://store.scottsbt.com
Work In Progress
Able Gold R10
Bootstrap 3.3

nadeem
Captain (CAPT)
Captain (CAPT)
Posts: 258
Joined: Tue Jul 31, 2012 7:23 pm

Re: Meta tag code

Post by nadeem » Fri Apr 10, 2015 2:50 am

Are you able to achieve your desired goal? This is super easy to make it work as rmaweb suggested. You just need to locate the following code inside BindMetaTags() function:

Code: Select all

if (!string.IsNullOrEmpty(catalogObject.MetaDescription))
{
   htmlHead.Append(Environment.NewLine);
   htmlHead.Append(string.Format("<meta name=\"description\" content=\"{0}\" />", HttpUtility.HtmlEncode(catalogObject.MetaDescription)));
}

if (!string.IsNullOrEmpty(catalogObject.MetaKeywords))
{
    htmlHead.Append(Environment.NewLine);
    htmlHead.Append(string.Format("<meta name=\"keywords\" content=\"{0}\" />", HttpUtility.HtmlEncode(catalogObject.MetaKeywords)));
}
and replace with

Code: Select all

if (catalogObject.CatalogNodeType == CatalogNodeType.Category)
{
if (!string.IsNullOrEmpty(catalogObject.MetaDescription))
{
    htmlHead.Append(Environment.NewLine);
    htmlHead.Append(string.Format("<meta name=\"description\" content=\"{0}\" />", HttpUtility.HtmlEncode(catalogObject.MetaDescription)));
}
else 
{
    htmlHead.Append(Environment.NewLine);
    htmlHead.Append(string.Format("<meta name=\"description\" content=\"{0}\" />", HttpUtility.HtmlEncode(catalogObject.Name)));
}

if (!string.IsNullOrEmpty(catalogObject.MetaKeywords))
{
    htmlHead.Append(Environment.NewLine);
    htmlHead.Append(string.Format("<meta name=\"keywords\" content=\"{0}\" />", HttpUtility.HtmlEncode(catalogObject.MetaKeywords)));
}
else
{
    htmlHead.Append(Environment.NewLine);
    htmlHead.Append(string.Format("<meta name=\"keywords\" content=\"{0}\" />", HttpUtility.HtmlEncode(catalogObject.Name)));
}
}
else
{
if (!string.IsNullOrEmpty(catalogObject.MetaDescription))
{
   htmlHead.Append(Environment.NewLine);
   htmlHead.Append(string.Format("<meta name=\"description\" content=\"{0}\" />", HttpUtility.HtmlEncode(catalogObject.MetaDescription)));
}

if (!string.IsNullOrEmpty(catalogObject.MetaKeywords))
{
    htmlHead.Append(Environment.NewLine);
    htmlHead.Append(string.Format("<meta name=\"keywords\" content=\"{0}\" />", HttpUtility.HtmlEncode(catalogObject.MetaKeywords)));
}
}
Edit: Wrapped the code inside if...else to make it specific to the category objects.
This should work the way you want it.

Post Reply