trilbymedia / grav-plugin-flex-objects

Powerful and supremely flexible object support for Grav
MIT License
38 stars 10 forks source link

Feature request: Way to specify Object path / Routing by Flex Type field #161

Open dexterxx-pl opened 2 years ago

dexterxx-pl commented 2 years ago

Prior to https://learn.getgrav.org/17/advanced/flex/using

Right now there's nice, but basic way to reach each Flex Object by eg. GETting url's like:

https://www.domain.com/directories/directory:contacts/id:ki2ts4cbivggmtlj https://www.domain.com/contacts/id:ki2ts4cbivggmtlj

Let say my Flex Type is

{
  "id": "string:generated by grav",
  "name": "string",
  ...
}

with example object:

{
  "id": "alotoftrashgenericchars",
  "name": "beauty",
  ...
}

I would like to specify in my blueprint something like:

config:
  site:
    object-url: 'i-am-so-{{name}}'

So I would be able to call on my instance:

https://www.domain.com/contacts/i-am-so-beauty

instead of

https://www.domain.com/contacts/id:alotoftrashgenericchars

which will render for me that object nicely with better seo path.

Possibility to use / in object-url would be also nice to have.

(Let's say for simplifying that let's first just get first matching object and don't bother on eventual duplicates, k?)

dexterxx-pl commented 2 years ago

BTW

https://www.domain.com/contacts/name:beauty

would be also improvement without adding new config parameter.

dexterxx-pl commented 2 years ago

I've found that defining key in our storage on specified field

  data:
    storage:
      options:
        indexed: true
        key: fieldname                # in above example the 'name' would be the value
        case_sensitive: false

I may call

https://www.domain.com/contacts/id:beauty

(but no without id:)

I was started to diggin how user accounts are handled by grav itself, so It quite-supports my case

http://www.domain.com/admin/accounts/users/test

but I still dunno...