Results 1 to 9 of 9

Thread: Use id column to build Details link

  1. #1
    User
    Join Date
    11-16-11.
    Location
    Hamburg
    Posts
    39

    Default Use id column to build Details link

    Hello,

    Is it possible to use raw table column like `id` to build the "Details" link?
    For example, I have a page with metamodel listing: http://domain.tld/people/

    I want the "Details" link to be: http://domain.tld/people/5212

    In the demo installation "Movie Database" they use aliases for that, but I don't want to create redundant data when the simple ID is enough for me. And even if I wanted to use aliases, I can't figure out the way to mass-generate them. I have a database with 6000+ records, can't possible generate them one by one.

  2. #2
    User zonky's Avatar
    Join Date
    11-29-11.
    Location
    Berlin
    Posts
    159

    Default

    You can use the alias Attribute with id as value... but its not possible to use a integer as alias. Contao add ‚id-‚ automaticaly.. you can use an Owen prefix

  3. #3
    User
    Join Date
    11-16-11.
    Location
    Hamburg
    Posts
    39

    Default

    In that case – how do I generate the aliases for the existing 6000+ records?
    Or any other attribute, for example – combined values?

  4. #4
    User zonky's Avatar
    Join Date
    11-29-11.
    Location
    Berlin
    Posts
    159

    Default

    If you use the latest MM Version, you can try the „multipe editing“ with edit all - or you build the value in phpmyadmin
    Last edited by zonky; 07/19/2018 at 20:11.

  5. #5
    User
    Join Date
    11-16-11.
    Location
    Hamburg
    Posts
    39

    Default

    There is no "Generate aliases" button in MetaModels, like in Contao for Pages, for example. So, now the only way to do it is check the "Always save" checkbox in Input screen, and then "Edit multiple" records. Overriding is not possible, since alias is unique, and php can't handle editing of 6000 records at once, the only option is to edit them in portions, like every 50 records... It's unthinkable
    Same goes for adding "Combined values" attribute to existing MetaModels btw - because those only generated on save, not on render.

    May be I should post a feature request on Github?

  6. #6
    User zonky's Avatar
    Join Date
    11-29-11.
    Location
    Berlin
    Posts
    159

    Default

    Quote Originally Posted by vini View Post
    There is no "Generate aliases" button in MetaModels, like in Contao for Pages, for example. So, now the only way to do it is check the "Always save" checkbox in Input screen, and then "Edit multiple" records. Overriding is not possible, since alias is unique, and php can't handle editing of 6000 records at once, the only option is to edit them in portions, like every 50 records... It's unthinkable
    Same goes for adding "Combined values" attribute to existing MetaModels btw - because those only generated on save, not on render.

    May be I should post a feature request on Github?
    Currently, the only way is to use „Edit multiple“... you can add your wishes as FR in Github..

    It‘s not possible to use phpMyAdmin?

  7. #7
    User zonky's Avatar
    Join Date
    11-29-11.
    Location
    Berlin
    Posts
    159

    Default

    another way would be to bypass the attribute Alias...

    You can find the ID in your template in the array node [raw] (see http://metamodels.readthedocs.io/en/...templates.html) and create your own URL to the detail page - there you can catch the ID with a filter rule "Own SQL"... that's it!

  8. #8
    User
    Join Date
    11-16-11.
    Location
    Hamburg
    Posts
    39

    Default

    Quote Originally Posted by zonky View Post
    another way would be to bypass the attribute Alias...

    You can find the ID in your template in the array node [raw] (see http://metamodels.readthedocs.io/en/...templates.html) and create your own URL to the detail page - there you can catch the ID with a filter rule "Own SQL"... that's it!
    This actually worked! Thank you for the idea.

    Just for the reference:

    1. The filter type is "Custom SQL"

    2. Actual query looks like this:
    Code:
    SELECT id FROM {{table}} WHERE id={{param::get?name=auto_item}}
    3. The details link in the template is built like this:
    PHP Code:
    <a href="<?= $arrItem['jumpTo']['url'] . '/' $arrItem['raw']['id'?>"></a>

  9. #9
    User zonky's Avatar
    Join Date
    11-29-11.
    Location
    Berlin
    Posts
    159

    Default

    PHP Code:
    SELECT id FROM {{table}} WHERE id={{param::get?name=auto_item&default=0}} 
    if auto_item not set

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •