You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assume you have two MetaModels, e.g. mm_items and mm_categories or something similar. Assume you want to create a frontend list that shows you all items of a specific category. Furthermore you have a detail page, where you show the details of a single item. Now assume you want the jumpTo link of that single item to point back towards the item list of the category. In theory this should be possible, by inserting the specific {{link_url::*}} for the jumpTo page of the category list and selecting the correct filter (which filters the items by category). This is also explained in the german Contao Wiki (MetaModels Beispiel 2 - Detailansicht erstellen).
However, this does not seem to work currently. Assume your item list for a specific category is under the following URL:
category/lorem-ipsum.html
Where lorem-ipsum is the alias of the category and "Lorem ipsum" would be the name of the category. This should also be the URL where the back-link points to in the detail list view of a specific item. However, the actual generated URL will be the following:
category/Lorem ipsum.html
So instead of using the alias, the system erroneously retrieves the name of the category.
publicfunctiongetFilterUrlValue($varValue)
{
// We are parsing as text here as this was the way before this method was implemented. See #216.$arrResult = $this->parseValue(array($this->getColName() => $varValue), 'text');
return urlencode($arrResult['text']);
}
i.e. it returns the user defined textual representation of the foreign column - which is the category's name in this case. Instead the call should probably go to MetaModels\Attribute\Select\Select::getFilterUrlValue which, I am guessing, would return the correct value of the alias field. So maybe this is just a polymorphism problem or something? Because the function $this->getMetaModel()->getAttributeById($this->get('attr_id')) actually returns a MetaModels\Attribute\Select\MetaModelSelect object and not a MetaModels\Attribute\Select\Select object.
Problem description
Assume you have two MetaModels, e.g.
mm_items
andmm_categories
or something similar. Assume you want to create a frontend list that shows you all items of a specific category. Furthermore you have a detail page, where you show the details of a single item. Now assume you want thejumpTo
link of that single item to point back towards the item list of the category. In theory this should be possible, by inserting the specific{{link_url::*}}
for thejumpTo
page of the category list and selecting the correct filter (which filters the items by category). This is also explained in the german Contao Wiki (MetaModels Beispiel 2 - Detailansicht erstellen).However, this does not seem to work currently. Assume your item list for a specific category is under the following URL:
Where
lorem-ipsum
is the alias of the category and "Lorem ipsum" would be the name of the category. This should also be the URL where the back-link points to in the detail list view of a specific item. However, the actual generated URL will be the following:So instead of using the alias, the system erroneously retrieves the name of the category.
Possible cause
I debugged through the code a little bit and the problem seems to originate from MetaModels\Filter\Setting::generateFilterUrlFrom.
More specifically: the function call
$objAttribute->getFilterUrlValue(...)
actually calls MetaModels\Attribute\Base::getFilterUrlValue, which simply doesi.e. it returns the user defined textual representation of the foreign column - which is the category's name in this case. Instead the call should probably go to MetaModels\Attribute\Select\Select::getFilterUrlValue which, I am guessing, would return the correct value of the alias field. So maybe this is just a polymorphism problem or something? Because the function
$this->getMetaModel()->getAttributeById($this->get('attr_id'))
actually returns aMetaModels\Attribute\Select\MetaModelSelect
object and not aMetaModels\Attribute\Select\Select
object.References
Backlink funktioniert nicht
MetaModels - erste Versuche - im Wiki
The text was updated successfully, but these errors were encountered: