I'm trying to create a mechanism for informing users that a particular entry is not available in the selected language, and providing a link to read the article in an alternative language.
Therefore, if one of my secondary locales returns a 404 for a particular URL and goes to a localised 404 error template, is there a way to check in the 404 template if the corresponding URL path matches an entry in my main locale, so I can link to that entry from the 404 page?
I think what I want is a method for searching for an entry using a string containing the complete URL path, but I don't think that’s available, so what would be the best alternative?
getUrl()
function.. Go toBaseElementModel->getUrl()
and you'll see what happens there.. just copy/paste the function in your pluginVariable.php (with the entryId param as) and include a check whether the entry for that local exists and try to fetch the one in your local if not$url = UrlHelper::getSiteUrl($path, null, null, "your new local eg. fr or en or whatever the handle is");
In your template you just use{{ craft.pluginHandle.getUrl(entryId) }}