D
D
dblearn942019-12-12 14:48:41
Yii
dblearn94, 2019-12-12 14:48:41

Url manager for url from root?

There are entities:

  1. Category (blog)
  2. Page (blog)
  3. Product category
  4. Product

All of them should be opened by url leading from the root, without prefixes like 'catalog' or 'blog' and so on.
eg: site/news/page-1 (page page-1 whose category_id points to the category news )
In general, what is the right way to implement this? (url generation, parsing and routing)
My UrlManager plan :
Create a table:
id | url | src_id | type
where:
url - full url from the root ( /news/page-1 )
src_id - resource that should be opened by this link
type - resource type, enum ( 0 - blog page, 1 - blog category, 2 - product category, 3 - product), etc.
Well, that's all, work with this table.
What do you think ?
Who came across please tell me how best to implement this, what could be the problems, etc.?
Isn't my version too primitive, isn't it "vlob"?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Gamov, 2019-12-12
@slowdream

Isn't it "head-on" - A "head-on" solution is often better than crutches and perversions (when huge packages are downloaded for simple functionality).
If this solution suits you, it is clear and logical - use it. As soon as this functionality is no longer enough, you will already be thinking about upgrading or rewriting, but with a clear vision of what exactly you need from the new version.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question