Post by david.gilbert » Tue Oct 07, 2008 7:12 pm

I've been Compiling all of my SEO Contribs into one complete Package for OpenCart 0.7x

This is to replace the Google Tools and URL Alias  Contribs previously posted. Many Enhancements have been made to the URL Alias function including the use of yoursite.com/category/product.html style urls.

This package will give you:
  • Full URL Alias Support with URL Alias Generator
  • Google analytics tracking and verify meta tag support.
  • Automagic Google Sitemap Generator.
All features appear as a new SEO tab in Admin -> Configuration -> Settings.

The Generate URL Aliases option appears under the Admin -> Configuration Menu.

Just drop the files into your site root (all files are in correct folders) then choose to enable which ever feature(s) you like.

A Big thanks to Bruce for all the help with the creation of this pack!

-Dave

Attachments

Last edited by david.gilbert on Sat Oct 11, 2008 10:00 am, edited 1 time in total.

Professional Website Services - http://www.davidmgilbert.com/


Active Member

Posts

Joined
Sun Jan 06, 2008 5:02 pm
Location - Mount Compass, South Australia

Post by david.gilbert » Tue Oct 07, 2008 7:22 pm

One small note I forgot to mention:

The Google Sitemap addon uses the URL Alias table from the database to generate the sitemap. Even if you are not using search engine friendly URL's, you need to go to Admin -> Configuration -> Generate URL Alias to populate the URL Alias Table for the Google Sitemap to work.

The Google Sitemap controller determines the URL Styles being used and will create the sitemap accordingly for you.

-Dave
Last edited by david.gilbert on Tue Oct 07, 2008 9:05 pm, edited 1 time in total.

Professional Website Services - http://www.davidmgilbert.com/


Active Member

Posts

Joined
Sun Jan 06, 2008 5:02 pm
Location - Mount Compass, South Australia

Post by jty » Fri Oct 10, 2008 7:06 pm

I have this working now on 0.7.8 with Bruce's Sub category Code

After reading through the thread at http://forum.opencart.com/index.php/topic,1677.0.html

In generate_url_alias.php I replaced

Code: Select all

/*generate categories & subcategories
        $sql = "select c.parent_id, c.path, cd.name from category_description cd left join category c on (c.category_id = cd.category_id)";
        $this->_generate_url_alias($sql, 'controller=category&path={0}', array('path'), array('name'));
with
//generate category
        $sql = "select category_id, name from category_description";
        $this->_generate_url_alias($sql, 'controller=category&path={0}', array('category_id'), array('name'));

        //generate sub-category into category
        $sql = "select category.parent_id, category.category_id, category_description.category_id, category_description.name FROM category, category_description WHERE category.category_id = category_description.category_id";
        $this->_generate_url_alias($sql, 'controller=category&path={0}_{1}', array('parent_id', 'category_id'), array('name'));
I also had to add
$this->_insert_url_alias('controller=search&action=page', 'search.html');
$this->_insert_url_alias('controller=account_forgotten', 'forgotten-password.html');

I don't know if this is the correct way or the incorrect way but it works for me. Not being a programmer, I have to resort to desperate measures  8)
Last edited by jty on Fri Oct 10, 2008 7:28 pm, edited 1 time in total.

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by Qphoria » Fri Oct 10, 2008 7:36 pm

that is odd considering bruce and I both use the tree class framework.

I an going to be redoing the subcat contrib to have an admin panel that can allow many different configurations for 079+

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jty » Fri Oct 10, 2008 8:30 pm

From the code of Bruce's that I found, which starts off with tmcguire, Bruce used
'href' => $url->href('category', false, array('path' => $result['category_id'])),

Your contribution uses
'href'  => $url->href('category', false, array('path' => $result['path'])),

Somehow, the use of either category_id or path in the subcategory menu link changes the subcategory-product link
I dunno. Too hard for me  :D

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by Qphoria » Fri Oct 10, 2008 9:05 pm

Yea, that goes back to the original fix I offered in the old URL Alias Generator thread:
http://forum.opencart.com/index.php/top ... ml#msg7483

Depending on if david and bruce used "category_id" again instead of "path" would probably be the difference here.
But it looks like they are using the code fix I offered from the other thread, tho you reverted it back to the old code. So I'm not sure why it doesn't work with my cat menu.  I will take a look
Last edited by Qphoria on Fri Oct 10, 2008 9:10 pm, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jty » Fri Oct 10, 2008 9:15 pm

Qphoria wrote: Depending on if david and bruce used "category_id" again instead of "path" would probably be the difference here.
But it looks like they are using the code fix I offered from the other thread. So I'm not sure why it doesn't work with my cat menu.  I will take a look
Looks to me like this SEO contribution is using path for the subcategory URL, hence your sub menu works for sub categories
But it's using category_id for the products so Bruce's subcategory product links work but yours don't but your subcategory link works but Bruce's don't

And that is why I got confused  ;D
Unless I'm reading it all wrong which is quite possible given I have no idea what I'm doing in code.

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by Qphoria » Fri Oct 10, 2008 9:22 pm

Ok, I installed this contrib on my 0.7.8 test site (fresh install) and I'm getting:
Notice: Undefined offset: 1 in D:\EasyWAMP\www\opencart078a\library\application\router.php on line 74

right off the bat for ALL links. The page never changes. I've not made any admin side changes yet.

-EDIT-
Now that I've run the Generate URL Alias thing, that error goes away, until I follow the path to my product. On the product page, it comes back.
Last edited by Qphoria on Fri Oct 10, 2008 9:28 pm, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Fri Oct 10, 2008 9:28 pm

jty wrote: Did you edit your htaccess file?

I also had to do this one to be able to turn off the SEO

Code: Select all

In this file:
library/environment/url.php
change:

if (!preg_match('/\/admin\/index.php/',$_SERVER['PHP_SELF'])) {

to:

if ((!preg_match('/\/admin\/index.php/',$_SERVER['PHP_SELF'])) && ($this->config->get('config_url_alias'))) {
But I don't want to turn off url alias.. thats the whole point of this contrib.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Fri Oct 10, 2008 9:38 pm

Ok, without using ANY subcategory contribs, the product link is already broken. There isn't even one in the URL_Alias table in the admin area. I'm not sure how a subcategory mod could add an alias

I have
Category 1 -> category-1.html (correct)
-- Cat1 Sub1  -> cat1-sub1.html (correct)
---- Sub1 SubA  -> sub1-suba.html (correct)
------ Product 1 -> none!

That is just following the default opencart structure without any category sidebox contribs.
Last edited by Qphoria on Fri Oct 10, 2008 9:40 pm, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by david.gilbert » Fri Oct 10, 2008 10:09 pm

ok.. i'm working on a second release, some issues have popped up with the google sitemaps in testing. I built this contrib on my codebase @ opencart-extras (1.02)

I will install 0.7.8 again on my testing server and get it all fine tuned over the next day or 2 then re-release it.

-Dave

Professional Website Services - http://www.davidmgilbert.com/


Active Member

Posts

Joined
Sun Jan 06, 2008 5:02 pm
Location - Mount Compass, South Australia

Post by david.gilbert » Sat Oct 11, 2008 10:00 am

New File Released

Fixes
  • Put the correct Generate_URL_ALIAS.php in place (was still the older version)
  • Fixed Google sitemaps issues
If your config.php & admin/config.php does not already have it, Add the following line

Code: Select all

define('HOSTING_DIR', '/path/to/opencart'); 
Attached to both this and first post!

-Dave

Attachments

Last edited by david.gilbert on Sat Oct 11, 2008 10:23 am, edited 1 time in total.

Professional Website Services - http://www.davidmgilbert.com/


Active Member

Posts

Joined
Sun Jan 06, 2008 5:02 pm
Location - Mount Compass, South Australia

Post by jty » Sat Oct 11, 2008 2:13 pm

Thanks David, it works for sub category products now
I had to make a tiny change to Bruce's sub category code - changed from 'category_ID' to 'path'
Qphoria's sub category menu should work as that already uses 'path'

I found 2 missing URLS

Code: Select all

$this->_insert_url_alias('controller=search&action=page', 'search.html');
$this->_insert_url_alias('controller=account_forgotten', 'forgotten-password.html');
Thanks for such a fast fix

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by bruce » Sat Oct 11, 2008 4:02 pm

jty wrote: Thanks David, it works for sub category products now
I had to make a tiny change to Bruce's sub category code - changed from 'category_ID' to 'path'
Hi jty,

Could you please post the change you mentioned above, as a code snippet. I am not entirely sure where you meant.

thanks

Bruce

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by jty » Sat Oct 11, 2008 4:18 pm

Hi Bruce,
Over here http://forum.opencart.com/index.php/topic,654.15.html
On January 06, 2008, in category.php

change

Code: Select all

'href' => $url->href('category', false, array('path' => $result['category_id'])),
to

Code: Select all

href' => $url->href('category', false, array('path' => $result['path'])),
ie change category_ID to path
This will make your code work with this SEO contribution

Thanks for your code

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by Qphoria » Tue Oct 14, 2008 8:44 pm

jty wrote: Hi Bruce,
Over here http://forum.opencart.com/index.php/topic,654.15.html
On January 06, 2008, in category.php

change

Code: Select all

'href' => $url->href('category', false, array('path' => $result['category_id'])),
to

Code: Select all

href' => $url->href('category', false, array('path' => $result['path'])),
ie change category_ID to path
This will make your code work with this SEO contribution

Thanks for your code

A little more detail about path vs category_id
http://forum.opencart.com/index.php/top ... ml#msg7483

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by bruce » Tue Oct 14, 2008 8:46 pm

Hi Q,

Its not related to this thread but a fix for some old code in the subcategories module thread he linked to.

cheers

Bruce

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by Qphoria » Tue Oct 14, 2008 9:15 pm

bruce wrote: Hi Q,

Its not related to this thread but a fix for some old code in the subcategories module thread he linked to.

cheers

Bruce
Right. I was just referring more to my particular post in that thread that explains more why I used path instead of the previous uses of category_id. I too at one point had category_id in my code until I realized that path worked better for the hierarchy.

;)

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by bruce » Wed Oct 15, 2008 7:06 am

I use path too. It was a genuine bug in the posted code.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by Qphoria » Wed Oct 15, 2008 8:41 am

bruce wrote: I use path too. It was a genuine bug in the posted code.
Oh sorry

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 6 guests