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

addToUrl hängt ein "_local=..." als GET-Parameter an #1257

Closed
zonky2 opened this issue Dec 20, 2017 · 3 comments
Closed

addToUrl hängt ein "_local=..." als GET-Parameter an #1257

zonky2 opened this issue Dec 20, 2017 · 3 comments
Assignees
Labels
Milestone

Comments

@zonky2
Copy link
Contributor

zonky2 commented Dec 20, 2017

Wird in einem Template eine URL-Generierung erzeugt

$ortUrl = '<a href="'  . \Frontend::addToUrl('orderBy=schulungsort_ort&orderDir=ASC') . '">Ort</a>';

wird ein _locale=de als GET-Parameter angehangen und nach erneutem Aufruf ist der Parameter "in der URL" als /_locale/de ... nach erneutem Aufruf kommt eine 404

siehe https://github.com/contao/core-bundle/blob/master/src/Resources/contao/classes/Frontend.php#L441

Workaround: ..._locale=& mit als Parameter in die addToUrl

C 4.4.8

@Toflar
Copy link
Member

Toflar commented Dec 20, 2017

/cc @aschempp

@leofeyer leofeyer added the bug label Dec 21, 2017
@leofeyer leofeyer added this to the 4.4.10 milestone Dec 21, 2017
@leofeyer leofeyer self-assigned this Dec 21, 2017
@leofeyer
Copy link
Member

Fixed in a21e52b.

@zonky2
Copy link
Contributor Author

zonky2 commented Dec 21, 2017

THX!

@leofeyer leofeyer modified the milestones: 4.4.10, 4.4 May 14, 2019
leofeyer pushed a commit that referenced this issue Feb 7, 2020
Description
-----------

In a project of ours we dynamically injected a DCA filter into

```php
$GLOBALS['TL_DCA']['tl_foo']['list']['sorting']['filter']
```

via an `onload_callback`. However, in our case we wanted to add a query like this:

```sql
foo NOT IN (…)
```

Initially we added the filter like this:

```php
$GLOBALS['TL_DCA']['tl_foo']['list']['sorting']['filter'][] = ['foo NOT IN ('.implode(',', $ids).')'];
```

However, since Contao assumes that these filters are _always_ a placeholder/value pair, the placeholders and values will mismatch in the final query and thus it results in a wrong SQL query, when user defined filter is selected for example.

As a workaround we implemented it like this:

```php
$GLOBALS['TL_DCA']['tl_foo']['list']['sorting']['filter'][] = ['(foo NOT IN ('.implode(',', $ids).') AND 1=?)', 1];
```

so that there is no placeholder/value mismatch anymore. But it would be convenient (and would save some debugging time …) if one could simply define a filter without a placeholder like this:

```php
$GLOBALS['TL_DCA']['tl_foo']['list']['sorting']['filter'][] = 'foo NOT IN ('.implode(',', $ids).')';
```

This PR would allow that.

Commits
-------

497a3abc Allow definition of filters without placeholder values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants