Opencart static and opencart pseudo-static methods, how to remove and modify the copyright information at the bottom of opencart powered by opencart

Source: Internet
Author: User
Tags opencart

Opencart static and opencart pseudo-static methods, how to remove and modify the copyright information at the bottom of opencart powered by opencart

I analyzed the URL link of opencart today and summarized some small experiences.
Opencart is a lightweight MVC framework, and the overall thinking is clear.
URL reconstruction is the classification as an example.
OBy default, pencart supports URL rewriting.You only need to enable this function in the background, but the system has some shortcomings. The following problems are summarized.
1. cannot automatically generate Seo keyword
2. The SEO keyword value is not unique.

For the first problem, I solve it as follows:
A common method used by other systems is to automatically generate Seo keyword using the product name. Generally, a friendly URL is generated, which generally only contains letters and numbers.
Here we can replace it with a regular expression.
However, it's not just a replacement. Another special case is that if the product name is all special characters, for example, if I add a Chinese product, the product is "brain platinum"
Seo keyword is empty, so how can we achieve pseudo-static? In this case, automatic replacement will not work.
In this case, if all the characters are special characters, I will directly generate the form of category-{$ category_id.

Second question
How can we understand that the value of urlkey is not unique.
For example, I add a new category 1, and then add "mycategory" to the SEO keyword in data.
Then, I will create another category 2, and I will also add "mycategory" to the SEO keyword in data.
In this way, there will be a problem, that is, both URLs have one, you will not be able to access Classification 2.

Well, there are a lot of theoretical points. Let's do it.
First, the data table that stores the SEO keyword is url_alias.ProgramWhere is the data inserted into the table.
Find the/admin/model/CATALOG/category. php file.

About 20-30 (add category), about 50-60 (modify category), that is
If ($ data ['keyword']) {
$ This-> DB-> query ("insert ". db_prefix. "url_alias set query = 'category _ id = ". (INT) $ category_id. "', keyword = '". $ this-> DB-> escape ($ data ['keyword']). "'");
}
Opencart static and opencart pseudo-static methods, how to remove and modify the copyright information at the bottom of opencart powered by opencart

To static:

Converting opencart to static is an important issue! This is also the first time opencart is used! Maybe I am affected by the conversion from Zen-cart to static! So I thought I only needed to upload ".. htaccess" to the server and directory! Then open the opencart to static button!

But the results are beyond my imagination! He is exactly the same as before! That is, the dynamic URL address. At that time, I thought it must be my ". htaccess" error! So I asked my friend to get a ". htaccess". Of course, it is used by opencart (different websites use ". htaccess" instead of static resources), but it still doesn't work! So I can only upload the original program to the server! Then reinstall it! Result: manually upload the product to the website! Still the same! As a result, I am speechless. To put it bluntly (of course, the program cannot be justified in many cases), I set ". htaccess "empty file, upload to the website's directory and put". set "htaccess" to 777, and I set ". htaccess can also be downloaded, but I don't know why!

So I used the same method, but this time I started the test product! I uploaded the product myself! Only to find that the original test product is usable! You cannot upload your own files! So I started the database to see what is the difference between their data! There is data in a table "url_alias! And there are boring products! I uploaded no more! So we can find the product's keyword data in "url_alias" to find out the original information. The field "product tags:" is the same on the opencart background product editing page, only then can I know that the author of opencart wrote something different from others! The URLs of other files are automatically generated! But he is different! He entered it by himself! And you can write what you like! As long as you are the only one! Of course, it also brings some inconvenience to the business! However, it can greatly help URL optimization! This will be mentioned in the next article "opencart URL optimization !, Of course, classification is the same!

This enables opencart to be converted to static. Of course, it's a bit difficult to do this! In the self-built opencart batch upload, I will replace the URL address directly with the product name! Turn the space into a hyphen! In this way, everyone should not worry about a URL! Of course I did not mention it in my PHP batch upload! If I have time, I will write "batch upload opencart" and I will give it a serious explanation!

This is the content of opencart ". htaccess:

# 1.to use URL alias you need to be running Apache withmod_rewrite enabled.

#2. In your opencart directory rename htaccess.txt to. htaccess.

# For any support issues please visit: http://www.opencart.com

Rewriteengine on

Rewritecond % {http_host }! ^ Cheap-shoes-wholesale.com $ [Nc]

Rewriterule ^ (. *) $ http://cheap-shoes-wholesale.com/%1%l,r%301]

Options + followsymlinks

Rewriteengine on

Rewritebase/

Rewritecond % {request_filename }! -F

Rewritecond % {request_filename }! -D

Rewriterule ^ (.*)? * $ Index. php? _ Route _ = $1 [L, QSA] rewriteengine

========================================================== ==============================

Pseudo-static method:

We need to verify $ data ['keyword'] before this judgment to verify whether it is null, because only when there is no blank,
We can reconstruct the URL of this classification to make sense.
If ($ data ['keyword']) {Add the followingCode

... Oter code...
If (! $ Data ['keyword']) {
// Generate a friendly URL with only numbers and letters
$ Keywordurl = preg_replace ("/[^-0-9a-za-z] +/", "", str_replace ('','-', $ this-> DB-> escape ($ value ['name']);
// If the product name is a special character, it is changed to category-{$ category_id}. The ID is added to the automatically generated seokeywork.
$ Data ['keyword'] = strlen ($ keywordurl)> 0? $ Keywordurl. '-'. $ category_id: 'category'. '-'. $ category_id;
}
If ($ data ['keyword']) {
... Oter code...

You can modify the SEO keyword of the product in the same way.
Modify the/admin/model/CATALOG/product. php file
The method is the same and is not repeated here.

 

Remove or modify the powered by opencart method at the bottom of opencart:

 

Catalog \ view \ theme \ Default \ template \ common \ footer. TPL

Find <? PHP echo $ text_powered_by;?>
Delete it or modify it as needed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.