Post by billynoah » Sun Jun 22, 2014 1:41 am

URL validation in OpenCart has troubled me for a while so today in response to another thread I went ahead and finished this vQmod. The goal is to validate urls to make sure they are valid according to the following rule set:

1. product cannot be followed by anything
2. information cannot be followed by anything
3. manufacturer can only be followed by a product and must not exist more than once
4. a category can only be followed by another category or a product
5. a product must belong to adjacent category or manufacturer present in url
6. categories must belong to parents in order of appearance in url

I've done some preliminary testing and so far so good. If anyone finds bugs or has ideas for improvements please let me know!

Cheers

UPDATE: With a bit of feedback, more thorough testing and a slew of bug fixes this seems to be working as it should.

I've added a setting called ""allow_parents" to support product category validation for either all parent categories or only the directly assigned category. For instance, if product "cinema-display" belongs only to category "monitors" which is a subcategory of "desktops":
desktops/monitors/cinema-display will always be valid

If "allow_parents" is set to "true" then
desktops/cinema-display will also be valid.

If set to false then a url path ending in "cinema-display" will only be valid if immediately preceeded by "monitors". so:
monitors/cinema-display will be valid and but
desktops/cinema-display will not.
Last edited by billynoah on Tue Jun 24, 2014 12:26 pm, edited 10 times in total.

Image


Active Member

Posts

Joined
Tue Jan 15, 2013 12:46 pm

Post by IP_CAM » Sun Jun 22, 2014 2:02 am

Ok, I just played around after uploading your Mod.
This is a correct url:
http://www.ipc.li/shop/index.php?route= ... ry&path=20

those are incorrect url's, I have added another >>&category<<
http://www.ipc.li/shop/index.php?route= ... ry&path=20
http://www.ipc.li/shop/index.php?route= ... path=20_61
http://www.ipc.li/shop/index.php?route= ... ry&path=20

and here, this produces a default >>cannot be found<< Message.
http://www.ipc.li/shop/index.php?route= ... path=20_26

Either I don't understand the 'planned' purpose of your Mod, or then, what is it, visually,
supposed to do or prevent? With or without the Mod, I see no difference.
I feel like a real 'boozo'...

Ernie

UPDATE:

I found something. I figured...

http://www.ipc.li/os/errorlogs.jpg

my Teaks File (OpenShop Admin v.1.7 - OC v.1.5.6.1-4)
http://www.ipc.li/os/tweaks.zip

I posted the link to this Page on the OpenShop User Forum as well, it could be a problem, related to >>OpenShop Admin<< only...

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by billynoah » Sun Jun 22, 2014 3:21 am

Thanks Ernie -
was a simple mistake when i pasted the code for the uploaded version (missing closing tag character on vqmver). I've corrected & updated the attachment.

I should have mentioned that this is currently written only for validation of SEO urls like
opencart.com/category/product
not the default php route style
opencart.com/index.php?route=product/product&path=1_2&product_id=3

See working demo here:
http://oc-demo-1564.zuma-design.com

Maybe later this weekend I'll add support for php route urls.
Last edited by billynoah on Sun Jun 22, 2014 3:43 am, edited 1 time in total.

Image


Active Member

Posts

Joined
Tue Jan 15, 2013 12:46 pm

Post by billynoah » Sun Jun 22, 2014 3:38 am

To clarify further.. on my demo:
http://oc-demo-1564.zuma-design.com/components/monitors is valid, whereas:
http://oc-demo-1564.zuma-design.com/monitors/components is not, because components is not a subcategory of monitors.
http://oc-demo-1564.zuma-design.com/cam ... non-eos-5d is valid
http://oc-demo-1564.zuma-design.com/com ... non-eos-5d is not, because canon-eos-5d does not belong to components category.
http://oc-demo-1564.zuma-design.com/apple/imac is valid
http://oc-demo-1564.zuma-design.com/sony/imac is not, because imac does not belong to brand sony.
http://oc-demo-1564.zuma-design.com/about_us is valid
http://oc-demo-1564.zuma-design.com/about_us/imac is not for fairly obvious reasons.
And so on.

Without the validation you could have had any number of categories, products, brands, information links and even utter nonsense in any order in a url like:
http://oc-demo-1564.zuma-design.com/app ... non-eos-5d
and it still would have been treated as a valid url - which is absurd.

Image


Active Member

Posts

Joined
Tue Jan 15, 2013 12:46 pm

Post by billynoah » Tue Jun 24, 2014 5:17 am


Image


Active Member

Posts

Joined
Tue Jan 15, 2013 12:46 pm
Who is online

Users browsing this forum: No registered users and 8 guests