OblikStudio / kirby-link-field

Links field for Kirby.
MIT License
77 stars 10 forks source link

Problem if used with Pagebuilder Plugin #2

Closed DansCreative closed 5 years ago

DansCreative commented 5 years ago

Hi, I encountered a problem when the link field is used in the Pagebuilder Plugin. I think I found the source of the problem. Its in the type select input field in the panel. It seems like, that the first option get's a wrong value. It uses the label which is definded in the translation files. You can see it in the attached image. Thanks for the help :)

type-select-options

hdodov commented 5 years ago

This problem doesn't occur if I simply change the language to Deutsch. The label is shown as "Seite" but the value is page. I think the problem might be coming from Pagebuilder. Could you send over a zipped Starterkit where this problem is reproduced?

thin-k-design commented 5 years ago

I am not sure, if this is related, or another issue (probably the latter), but as the issue title says the same, here my problem:

The only type of link, that is not working inside the kirby-builder plugin is the file link. When I select file from the dropdown and click to select a file, the following is shown:

image

I only read some bits of the kirby API, but it seems the URL that the kirby-link-field is calling is not valid, I get in the console "the server responded with a status of 400 (Bad Request)" for the URL: {{domain}}/api/kirby-builder/pages/home+vorteile/fields/module+doubleslider+list+button/files?

The following URL for the link type page is working: {{domain}}/api/kirby-builder/pages/home+vorteile/fields/module+doubleslider+list+button/pages?

guidoferreyra commented 5 years ago

having the same issue here. When I select the page as link type I get :

No route found for path: "kirby-/pages/..." and request method: "GET"

Any help?

hdodov commented 5 years ago

@thin-k-design @guidoferreyra could you provide a ZIP file with a minimal example of the problem inside? I haven't used the page builder plugin and it would be hard for me to replicate the issue. I'd be very thankful if you could remove all unnecessary data/content and leave just the field that causes the issue, if possible.

thin-k-design commented 5 years ago

Hi, I have attached a composer file for a fresh installation with both plugins (kirby-builder and kirby-link-field); and the blueprint for the default template.

Run composer install and replace the file default.yml in blueprints. Then you can just edit the home page, add a modul and see the described problem.

test.zip

hdodov commented 5 years ago

@thin-k-design thank you very much for the ZIP, it helped a lot. It was an issue with the route names. My /files route was conflicting with Kirby's native (.*)/files route and the Builder plugin was using that instead. I simply changed my plugin's routes to /link-files and /link-pages.

I published version 2.0.1 and it appears to be working correctly now. I also added Composer autoloading for the Link class (I used include_once before).

@guidoferreyra could you test as well?

thin-k-design commented 5 years ago

@hdodov it worked! thanks, the only thing your plugin is missing would be a query parameter in the blueprint to filter the pages and files to show, it would be amazing ;)

hdodov commented 5 years ago

@thin-k-design great! I also thought that filtering the results would be a nice addition. You should add that as another issue so I can get back to it when I can.

guidoferreyra commented 5 years ago

It ddint worked for me, I‘m getting the same error as before.

Captura de pantalla 2019-08-01 a la(s) 09 45 33

guidoferreyra commented 5 years ago

And for some reason now I cant make it work inside a structure field. This structure is not inside the Pagebuilder and was working before the update.

It trows the following error.

Class 'Oblik\Kirby\LinkField\Link' not found

Captura de pantalla 2019-08-01 a la(s) 09 56 56

hdodov commented 5 years ago

The class not found error is occurring because since the last patch, it's autoloaded by Composer. I assume you're not using Composer? In that case, you could try something like:

include_once __DIR__ . '/site/plugins/link-field/src/Link.php`

...in your index.php.

Could you also send over a ZIP with a minimal reproduction of the error?

guidoferreyra commented 5 years ago

When I created a minimal reproduction case I didn‘t get the error buy in my site yes. So I tought it was other part of my code, but no. It finally worked when I changed the name to the mamp pro server, so strange...

I have to add the include_once code you said to the root index.php? It didn’t worked for me. Yes Im not using composer.

guidoferreyra commented 5 years ago

I managed to solve it adding the following to the index of the plugin. Is this ok?

include_once __DIR__ . '/src/Link.php'

hdodov commented 5 years ago

@guidoferreyra it's OK, but that code will likely be lost when you download the next version of the plugin. I need to look into ways of including the class without Composer.

It finally worked when I changed the name to the mamp pro server, so strange...

So is the error from your screenshot gone? Does it work? What fixed it?

hdodov commented 5 years ago

@guidoferreyra I published version 2.0.2 where the Link class should be loaded properly without Composer. Can you check that?

guidoferreyra commented 5 years ago

Works fine for me, thanks!