Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

record|link not working in listings loop #1398

Closed
peterboorsma opened this issue May 22, 2020 · 10 comments · Fixed by #1421
Closed

record|link not working in listings loop #1398

peterboorsma opened this issue May 22, 2020 · 10 comments · Fixed by #1421
Assignees
Labels
🐛 tag: bug This is a bug.

Comments

@peterboorsma
Copy link
Contributor

When you create a generic listing template (without a setcontent) to get all the records from a contenttype, the {{ record|link }} does not seem to work.

Example:

{% extends 'partials/_master.twig' %}
{% block main %}
{% for record in records %}
	<a href="{{ record|link }}">{{ record|title }}</a>
{% endfor %}
{% endblock main %}

Output is
https://site.name/contenttype
Should be:
https://site.name/contentype/recordslug

I also tested this with the standard themes (base-2018, skeleton) with the same results.


Bolt 4.0.0 RC19

@bobdenotter
Copy link
Member

Soo.. not a bug?

@peterboorsma
Copy link
Contributor Author

Tested it again on a clean Bolt4 install. It does work there, so it's not a bug but something wrong in this specific site. The only difference (I know of) between the tested sites seems to be that a standard install is multilingual and the other has just one locale.
I haven't got a clue. {{ record|link }} tags just won't show up anywhere in listings.

@peterboorsma
Copy link
Contributor Author

peterboorsma commented May 22, 2020

Aha. When I add /nl/ in the browser addres bar, the link appears. (But I don't want that. It's a 1 language site)
So... in https://my.site/contentlisting record|link in listings is empty
In https://my.site/nl/contentlisting the record|link tag does work.

@bobdenotter
Copy link
Member

Hmm, that does sound kinda buggy, though.. What do you get when you do {{ dump(record.extras) }}?

What does the yaml of the contenttype look like?

@peterboorsma
Copy link
Contributor Author

peterboorsma commented May 22, 2020

From my local machine:

array:10 [▼
  "title" => "test item 4"
  "image" => array:7 [▶]
  "link" => "/nl/diary-item/test-item-4"
  "editLink" => "/bolt/edit/7"
  "statusLink" => "/bolt/status/7?token=QZcsctMdFnQcYi0TDVjajEItwLnsly1wCqu1H8-gtCo"
  "deleteLink" => "/bolt/delete/7?token=KVFla47OzK17k4riEui9eXkop5vcEZn28VrPaQLga30"
  "duplicateLink" => "/bolt/duplicate/7"
  "icon" => "fa-file"
  "name" => "Diary"
  "singular_name" => "Diary-item"

]

From dev server (a cloned version: https://peter2.boors.ma/diary)

array:9 [▼
  "title" => "testitem 2"
  "link" => "/en/diary-item/testitem-2"
  "editLink" => "/bolt/edit/4"
  "statusLink" => "/bolt/status/4?token=XsjvCNw-nljwh2hsf0e1ZbsUwFV1e7D-mMqYYr14YAs"
  "deleteLink" => "/bolt/delete/4?token=Vfrj9olXZjxUX-ZylLzCgTZsg99qp6vaK15Arn6bBZo"
  "duplicateLink" => "/bolt/duplicate/4"
  "icon" => "fa-file"
  "name" => "Diary"
  "singular_name" => "Diary-item"
]

This is the complete contenttype:

diary:
    name: Diary
    singular_name: Diary-item
    fields:
        slug:
            type: slug
            uses: title
            group: Content
        title:
            type: text
            class: large
        image:
            type: image
            attrib: alt
            upload: diary
        body:
            type: html
            height: 300px
    record_template: item_1.twig
    #listing_template: listing_1.twig
    recordsperpage: 30
    default_status: published

@bobdenotter
Copy link
Member

Reopening.. There's something slightly weird here.

@bobdenotter bobdenotter reopened this May 24, 2020
@peterboorsma
Copy link
Contributor Author

Some additional info for this problem. Don't know if it's helpful...
First I did a clean composer install. I created a db in my PHPMyAdmin (not with the documented bin/console doctrine:database:create)
I used the standard contenttypes.yml with the standard contenttypes at first.
Then I added my own contenttypes and removed the locales: ['nl', 'en'] and localize: true rules from my contenttypes.
I added some test records and after that I changed the locale setting in config.yaml from locale: ['nl', 'en'] to locale: nl_NL
I think that was the moment I noticed empty fields in my test records. I thought that had to do with changing the locales so I just filled the empty fields again.

When I copied the project to remote (with a new empty db) the same problem appears:
Record links keep adding the /locale/ like this:
/nl/diary-item/testitem-5
instead of this
/diary-item/testitem-5

Probably related:
The {{ htmllang() }} tag does not return anything, it appears to be empty.

Some yaml info:

From services.yaml:

parameters:
    locale: 'en'
    # This parameter defines the codes of the locales (languages) enabled in the application
    app_locales: en|nl|es|fr|de|pl|it|hu|pt_BR|ja|nb|nn|nl_NL|nl_BE|is|ru
    app.notifications.email_sender: [email protected]
    bolt.table_prefix: bolt_
    bolt.backend_url: /bolt

From contenttypes.yaml:

diary:
    name: Diary
    singular_name: Diary-item
    fields:
        slug:
            type: slug
            uses: title
            group: Content
        title:
            type: text
            class: large
        image:
            type: image
            attrib: alt
            upload: diary
        body:
            type: html
            height: 300px
    record_template: item_1.twig
    recordsperpage: 30
    default_status: published

@peterboorsma
Copy link
Contributor Author

Update, could be related..
I updated a project from RC19 > RC20. All slugs from all records are now empty. I tried fixing them but the newly added slugs are not being saved.

The frontend template now returns an error:

An exception has been thrown during the rendering of a template ("Parameter "slugOrId" for route "record_locale" must match "[^/]++" ("" given) to generate a corresponding URL.").

Screenshot 2020-05-25 at 11 52 46

@bobdenotter bobdenotter added the 🐛 tag: bug This is a bug. label May 27, 2020
@bobdenotter bobdenotter added this to the Bolt 4.0.0 stable milestone May 27, 2020
@peterboorsma
Copy link
Contributor Author

Info update:

RC18 > RC20 update. When updating/saving a record the slug is empty. If I try to edit the slug, this is not saved. So I am unable to add/change the slug and the record gets "lost".

@peterboorsma
Copy link
Contributor Author

peterboorsma commented May 31, 2020

I updated the project to RC21. (Bob: westerkerkleeuwarden). I think this should be a new issue but that's for you to decide.
This is a list of "problems" that I encountered after the update:

All records "lost" their slugs.

Changes in content from certain field types won't show up in the frontend templates. Not even after I clear the cache, repeatedly.

When creating a new record, the slug is not automatically created. I made a screencast to illustrate it :)
https://www.dropbox.com/s/z9puc6i7pv1f7mp/Screen%20Recording%202020-05-31%20at%2022.14.41.mov?dl=0

Page breaks (with debug on) on the {{ htmllang() }} tag and on the {% if locales()|length %} tag:
An exception has been thrown during the rendering of a template ("Parameter "slugOrId" for route "record_locale" must match "[^/]++" ("" given) to generate a corresponding URL.").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 tag: bug This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants