Jump to content

Add meta titles and decription


lynnmcdee

Recommended Posts

  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

Ok, let's go that route.

 

It makes sense that in addition to meta-data, we also provide for any number of other settings associated with searching and searches through the database.

 

Granted that most people on these forums do not have a degree in Search Protocols and algorithms, still, we would be well advised to develop some other settings that would influence and control the search.

Link to comment
Share on other sites

Let's add to the file /class/cubecart.class.php, near line 692:

Was:
if (!$GLOBALS['catalogue']->searchCatalogue($_REQUEST['search'], $page, $catalogue_products_per_page)) {
  $GLOBALS['catalogue']->setCategory('cat_name', $GLOBALS['language']->navigation['search_results']);
  $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->common['search'], 'index.php?_a=search');
  $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->navigation['search_results'], currentPage());
  $GLOBALS['gui']->setError($GLOBALS['language']->catalogue['error_search_no_results']);
} else {
  $GLOBALS['catalogue']->setCategory('cat_name', sprintf($GLOBALS['language']->catalogue['notify_product_search'],$_REQUEST['search']['keywords']));
  $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->common['search'], 'index.php?_a=search');
  $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->navigation['search_results'], currentPage());
}
 
Now:
if (!$GLOBALS['catalogue']->searchCatalogue($_REQUEST['search'], $page, $catalogue_products_per_page)) {
  $GLOBALS['catalogue']->setCategory('cat_name', $GLOBALS['language']->navigation['search_results']);
  $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->common['search'], 'index.php?_a=search');
  $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->navigation['search_results'], currentPage());
  $GLOBALS['gui']->setError($GLOBALS['language']->catalogue['error_search_no_results']);
} else {
  $GLOBALS['catalogue']->setCategory('cat_name', sprintf($GLOBALS['language']->catalogue['notify_product_search'],$_REQUEST['search']['keywords']));
$GLOBALS['catalogue']->setCategory('seo_meta_description', $GLOBALS['config']->get('search_config', 'catalogue_search_seo_meta_description'));
$GLOBALS['catalogue']->setCategory('seo_meta_keywords', $GLOBALS['config']->get('search_config', 'catalogue_search_seo_meta_keywords'));
$GLOBALS['catalogue']->setCategory('seo_meta_title', $GLOBALS['config']->get('search_config', 'catalogue_search_seo_meta_title'));
  $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->common['search'], 'index.php?_a=search');
  $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->navigation['search_results'], currentPage());
}

The three non-indented lines are the new statements.

 

We will soon have a new configuration group, catalogue_search, with various settings in the group.
 

Link to comment
Share on other sites

In the file /admin/sources/element.navigation.inc.php, add:

To the $nav_items['settings'] array:
$lang['navigation']['nav_settings_search']        => '?_g=settings&node=search',

In the file /language/definitions.xml, add:

In the <group name="navigation"> section:
<string name="nav_settings_search"><![CDATA[Search Settings]]></string>

Create two new files named:

1. /admin/sources/settings.search.inc.php

2. /admin/skins/default/templates/settings.search.php

 

For file#2, the following are the contents (so far):

<form id="form-settings" action="{$PHP_SELF}" method="post" enctype="multipart/form-data">
<div id="seo" class="tab_content">
  <h3>{$LANG.settings.tab_seo}</h3>
  <fieldset><legend>{$LANG.settings.title_seo_meta_data}</legend>
    <div><label for="catalogue_search_seo_meta_title">{$LANG.settings.seo_meta_title}</label><span><input name="cs[catalogue_search_seo_meta_title]" id="catalogue_search_seo_meta_title" class="textbox" type="text" value="{$CS.catalogue_search_seo_meta_title}" /></span></div>
    <!-- <div><label for="catalogue_search_seo_path">{$LANG.settings.seo_path}</label><span><input name="cs[catalogue_search_seo_path]" id="catalogue_search_seo_path" class="textbox" type="text" value="{$CS.catalogue_search_seo_path}" /></span></div> -->
    <div><label for="catalogue_search_seo_meta_keywords">{$LANG.settings.seo_meta_keywords}</label><span><textarea name="cs[catalogue_search_seo_meta_keywords]" id="catalogue_search_seo_meta_keywords" class="textbox">{$CS.catalogue_search_seo_meta_keywords}</textarea></span></div>
    <div><label for="catalogue_search_seo_meta_description">{$LANG.settings.seo_meta_description}</label><span><textarea name="cs[catalogue_search_seo_meta_description]" id="catalogue_search_seo_meta_description" class="textbox">{$CS.catalogue_search_seo_meta_description}</textarea></span></div>
  </fieldset>
</div>
 
{include file='templates/element.hook_form_content.php'}

<div class="form_control">
  <input type="hidden" name="config[bftime]" value="600" />
  <input type="hidden" name="config[bfattempts]" value="5" />
  <input id="submit" type="submit" class="button" value="{$LANG.common.save}" />
  <input type="hidden" name="previous-tab" id="previous-tab" value="" />
</div>
<input type="hidden" name="token" value="{$SESSION_TOKEN}" />
</form>

 

Link to comment
Share on other sites

For file 1 in post#30, the following contents will database the meta-data you provide:

<?php
if (!defined('CC_INI_SET'))    die('Access Denied');
Admin::getInstance()->permissions('settings', CC_PERM_READ, true);

global $lang;

if (isset($_POST['cs']) && is_array($_POST['cs']) && Admin::getInstance()->permissions('settings', CC_PERM_EDIT)) {

    if ($GLOBALS['config']->set('search_config', '', $_POST['cs'])) {
        $GLOBALS['cache']->clear();
        $GLOBALS['main']->setACPNotify($lang['settings']['notify_settings_update']);
    } else {
        $GLOBALS['main']->setACPWarning($lang['settings']['error_settings_update']);
    }

    httpredir(currentPage());

}

###########################################

## Add content tabs
$GLOBALS['main']->addTabControl($lang['settings']['tab_seo'], 'seo', null, 'S');
$GLOBALS['gui']->addBreadcrumb($lang['common']['search'], currentPage());

$cs = $GLOBALS['config']->get('search_config');

$GLOBALS['smarty']->assign('CS', $cs);

$page_content = $GLOBALS['smarty']->fetch('templates/settings.search.php');

In post#29, we added code that will populate the skin's HTML meta-tags for the search results -- which is just a special type of category listing.

 

The next step is to populate the skin's HTML meta-data tags with this meta-data for the main Search form.

 

Then I think we are done!

Link to comment
Share on other sites

At the end of the file /classes/cubecart.class.php, the _search() function controls the customer's Search form. Make the following edit to add the Search meta-data to the HTML meta-data tags for this page:

Was:
        $content = $GLOBALS['smarty']->fetch('templates/content.search.php');
        $GLOBALS['smarty']->assign('PAGE_CONTENT', $content);
    }
}
 
Now:
        $content = $GLOBALS['smarty']->fetch('templates/content.search.php');
/* Put search to meta_data here. */
$cs = $GLOBALS['config']->get('search_config');
$meta_data    = array(
    'name'            => $GLOBALS['language']->common['search'],
    'path'            => null,
    'description'    => (isset($cs['catalogue_search_seo_meta_description'])) ? $cs['catalogue_search_seo_meta_description'] : '',
    'keywords'        => (isset($cs['catalogue_search_seo_meta_keywords'])) ? $cs['catalogue_search_seo_meta_keywords'] : '',
    'title'            => (isset($cs['catalogue_search_seo_meta_title'])) ? $cs['catalogue_search_seo_meta_title'] : '',
);
$GLOBALS['seo']->set_meta_data($meta_data);
        $GLOBALS['smarty']->assign('PAGE_CONTENT', $content);
    }
}

Reviewing post#1, the Registration page is also to have custom meta-data.

 

So, back to post#9.

Link to comment
Share on other sites

Regarding Registration, Could go under Customers or Customers/Customer List or under Settings. I prefer under Customers.
 
Customers
Inventory
File Manager
Settings

All good so far. :)

Link to comment
Share on other sites

Alright, we will add a new navigation item under Customers called Registration Settings which will be similar to Search Settings with currently only the Search Engines tab.

 

Note: It would be so cool to be able to incorporate registration meta-data into either of these mods:

http://www.cubecartforums.org/index.php?showtopic=17505

http://www.cubecartforums.org/index.php?showtopic=17706

Link to comment
Share on other sites

So, let's finish this by adding the code to allow custom meta-data for the registration form page.

 

Create a new file /admin/sources/customers.registration.inc.php:

<?php
if (!defined('CC_INI_SET'))    die('Access Denied');
Admin::getInstance()->permissions('settings', CC_PERM_READ, true);

global $lang;

if (isset($_POST['reg']) && is_array($_POST['reg']) && Admin::getInstance()->permissions('settings', CC_PERM_EDIT)) {

    if ($GLOBALS['config']->set('registration_config', '', $_POST['reg'])) {
        $GLOBALS['cache']->clear();
        $GLOBALS['main']->setACPNotify($lang['settings']['notify_settings_update']);
    } else {
        $GLOBALS['main']->setACPWarning($lang['settings']['error_settings_update']);
    }

    httpredir(currentPage());

}

###########################################

## Add content tabs
$GLOBALS['main']->addTabControl($lang['settings']['tab_seo'], 'seo', null, 'S');
$GLOBALS['gui']->addBreadcrumb($lang['account']['registration'], currentPage());

$reg = $GLOBALS['config']->get('registration_config');

$GLOBALS['smarty']->assign('REG', $reg);

$page_content = $GLOBALS['smarty']->fetch('templates/customers.registration.php');

Create a new file /admin/skins/default/templates/customers.registration.php:

<form id="form-settings" action="{$PHP_SELF}" method="post" enctype="multipart/form-data">
<div id="seo" class="tab_content">
  <h3>{$LANG.settings.tab_seo}</h3>
  <fieldset><legend>{$LANG.settings.title_seo_meta_data}</legend>
    <div><label for="registration_seo_meta_title">{$LANG.settings.seo_meta_title}</label><span><input name="reg[registration_seo_meta_title]" id="registration_seo_meta_title" class="textbox" type="text" value="{$REG.registration_seo_meta_title}" /></span></div>
    <!-- <div><label for="registration_seo_path">{$LANG.settings.seo_path}</label><span><input name="reg[registration_seo_path]" id="registration_seo_path" class="textbox" type="text" value="{$REG.registration_seo_path}" /></span></div> -->
    <div><label for="registration_seo_meta_keywords">{$LANG.settings.seo_meta_keywords}</label><span><textarea name="reg[registration_seo_meta_keywords]" id="registration_seo_meta_keywords" class="textbox">{$REG.registration_seo_meta_keywords}</textarea></span></div>
    <div><label for="registration_seo_meta_description">{$LANG.settings.seo_meta_description}</label><span><textarea name="reg[registration_seo_meta_description]" id="registration_seo_meta_description" class="textbox">{$REG.registration_seo_meta_description}</textarea></span></div>
  </fieldset>
</div>
 
{include file='templates/element.hook_form_content.php'}

<div class="form_control">
  <input type="hidden" name="config[bftime]" value="600" />
  <input type="hidden" name="config[bfattempts]" value="5" />
  <input id="submit" type="submit" class="button" value="{$LANG.common.save}" />
  <input type="hidden" name="previous-tab" id="previous-tab" value="" />
</div>
<input type="hidden" name="token" value="{$SESSION_TOKEN}" />
</form>

In the file /language/definitions.xml:

Add to the 'account' group:
<string name="registration" introduced="5.0.0"><![CDATA[Registration]]></string>
 
Add to the 'navigation' group:
<string name="nav_settings_registration"><![CDATA[Registration Settings]]></string>

In the file /admin/sources/element.navigation.inc.php:

Add to the $nav_items['customers'] array:
$lang['navigation']['nav_settings_registration']        => '?_g=customers&amp;node=registration',

In the file /classes/cubecart.class.php, about in the middle of the _register() function - near the bottom of the file:

Was:
            $content = $GLOBALS['smarty']->fetch('templates/content.register.php');
            $GLOBALS['smarty']->assign('SECTION_NAME', 'register');
            $GLOBALS['smarty']->assign('PAGE_CONTENT', $content);
 
Now:
            $content = $GLOBALS['smarty']->fetch('templates/content.register.php');
            $GLOBALS['smarty']->assign('SECTION_NAME', 'register');
/* Put registration to meta_data here. */
$reg = $GLOBALS['config']->get('registration_config');
$meta_data    = array(
    'name'            => $GLOBALS['language']->account['registration'],
    'path'            => null,
    'description'    => (isset($reg['registration_seo_meta_description'])) ? $reg['registration_seo_meta_description'] : '',
    'keywords'        => (isset($reg['registration_seo_meta_keywords'])) ? $reg['registration_seo_meta_keywords'] : '',
    'title'            => (isset($reg['registration_seo_meta_title'])) ? $reg['registration_seo_meta_title'] : '',
);
$GLOBALS['seo']->set_meta_data($meta_data);
            $GLOBALS['smarty']->assign('PAGE_CONTENT', $content);
Link to comment
Share on other sites

Hi Brian,

 

I don't know if I have done something wrong.  I followed all of the instructions.  But, when I have run a report on screaming frog the Search Engine meta information that I have entered has overwritten all of the category meta information. 

 

Any ideas?

Link to comment
Share on other sites

Please look at the raw HTML using your browser's View Source command for these two pages:

/sale-items.html

/search.html?_a=category&search[keywords]=Test

where Test is a word you know will result in a list of products found from the search.

 

Then also a standard category page.

 

Find the meta tags in the header section.

 

Verify what you see matches the values you have entered into the respective fields in the CubeCart admin. in other words, directly validate what "screaming frog" is telling you.

Link to comment
Share on other sites

Ok, that's what the HTML says.

 

Do you still have the desired meta-data in any of the admin Add/Edit Category, Search Engine tab? Or is the Advanced Search meta-data being displayed on the Category's Search Engine tab?

 

Then, look directly into the database, at the CubeCart_category table. Does the meta-data for all of the categories look proper?

 

What we need to determine is if the Advanced Search meta-data is being fetched while displaying a regular category, or has the Advanced Search meta-data actually replaced content in the database (and that would be extraordinarily implausible due to the way the Advanced Search meta-data is being databased).

 

The following is what my code looks like in cubecart.class.php, starting near line 692, in the _category() function:

            if (!$GLOBALS['catalogue']->searchCatalogue($_REQUEST['search'], $page, $catalogue_products_per_page)) {
                $GLOBALS['catalogue']->setCategory('cat_name', $GLOBALS['language']->navigation['search_results']);
                $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->common['search'], 'index.php?_a=search');
                $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->navigation['search_results'], currentPage());
                $GLOBALS['gui']->setError($GLOBALS['language']->catalogue['error_search_no_results']);
            } else {
                $GLOBALS['catalogue']->setCategory('cat_name', sprintf($GLOBALS['language']->catalogue['notify_product_search'],$_REQUEST['search']['keywords']));
$GLOBALS['catalogue']->setCategory('seo_meta_description', $GLOBALS['config']->get('search_config', 'catalogue_search_seo_meta_description'));
$GLOBALS['catalogue']->setCategory('seo_meta_keywords', $GLOBALS['config']->get('search_config', 'catalogue_search_seo_meta_keywords'));
$GLOBALS['catalogue']->setCategory('seo_meta_title', $GLOBALS['config']->get('search_config', 'catalogue_search_seo_meta_title'));
                $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->common['search'], 'index.php?_a=search');
                $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->navigation['search_results'], currentPage());
            }
        } else {
            if(!is_numeric($GLOBALS['config']->get('config', 'catalogue_products_per_page'))) {
                $catalogue_products_per_page = 10;
            } else {
                $catalogue_products_per_page = $GLOBALS['config']->get('config', 'catalogue_products_per_page');
            }
            $GLOBALS['catalogue']->searchCatalogue($_GET['cat_id'], $page, $catalogue_products_per_page);
            if ($_GET['cat_id'] == 'sale') { // Showing the Sale Items category
                $GLOBALS['catalogue']->setCategory('cat_name', $GLOBALS['language']->navigation['saleitems']);
$GLOBALS['catalogue']->setCategory('seo_meta_description', $GLOBALS['config']->get('config', 'catalogue_sale_seo_meta_description'));
$GLOBALS['catalogue']->setCategory('seo_meta_keywords', $GLOBALS['config']->get('config', 'catalogue_sale_seo_meta_keywords'));
$GLOBALS['catalogue']->setCategory('seo_meta_title', $GLOBALS['config']->get('config', 'catalogue_sale_seo_meta_title'));
                $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->navigation['saleitems'], currentPage());
            }
        }

        $GLOBALS['catalogue']->categoryPagination($page);

        // Display Product listing
        $GLOBALS['catalogue']->displayCategory();
    }
Link to comment
Share on other sites

Hi Brian,

 

I have worked my way back and re-instated the original code but it is still showing 'Advance Search'.  Do you know what file I should look more closely at???

 

The category pages have advance search (see below) instead of products

Advanced Search

 

Keywords *
Price Range -   Â±5%
In Stock
Featured Products Only
Link to comment
Share on other sites

  • 3 weeks later...
  • 2 months later...

Alright, we will add a new navigation item under Customers called Registration Settings which will be similar to Search Settings with currently only the Search Engines tab.

 

Note: It would be so cool to be able to incorporate registration meta-data into either of these mods:

http://www.cubecartforums.org/index.php?showtopic=17505

http://www.cubecartforums.org/index.php?showtopic=17706

 From post#36

 

I was only interested in adding the Registration Meta - specifically the TITLE - currently that page is not validating due to empty title. I have attempted to create and added all files and code changes you provided from #38 down, but #36 must refer to previous code that I don't know how to modify to get the Registration Settings to show in Admin.

 

I did comment out the old code with // on each line. Does that work properly with php files?? I had not included the else statement inside my commented lines. All is working as you expected now. Thank you again!!!

Link to comment
Share on other sites

I've been working through your code additions in this thread and have some concerns about the usefulness of the Search section. Having a Title on the Search pages Google chooses to use is good, as it eliminates one of their "html warnings". But I have a suspicion the code may have created a warning as well.

 

You had helped me previously to provide wording on the page so the customer could see what terms they had used for the search results. ie, My page says Products found matching 'mug' when mug is the search term.

$GLOBALS['catalogue']->setCategory('cat_name', sprintf($GLOBALS['language']->catalogue['notify_product_search'],$_REQUEST['search']['keywords']));

INSTEAD OF CURRENT

$GLOBALS['catalogue']->setCategory('cat_name', $GLOBALS['language']->navigation['search_results']);

Since your code in this thread provides the same Search Description and Meta Tags for all search results, I suspect Google will soon be complaining about that! Is there a way to tweak the code so these new lines around line 700 in cubecart.class.php incorporate the actual search terms in the wording? Something along the lines of "Dirty Butter Estates Collectibles Shoppe Search Results for " (from this new seo_meta_title) AND THEN the terms searched for.

$GLOBALS['catalogue']->setCategory('seo_meta_description', $GLOBALS['config']->get('search_config', 'catalogue_search_seo_meta_description')); 
$GLOBALS['catalogue']->setCategory('seo_meta_keywords', $GLOBALS['config']->get('search_config', 'catalogue_search_seo_meta_keywords'));
$GLOBALS['catalogue']->setCategory('seo_meta_title', $GLOBALS['config']->get('search_config', 'catalogue_search_seo_meta_title'));

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.




×
×
  • Create New...