Question

I'm making a multilingual Django-CMS site. I have a page that has some content in it that links to a child page, in such a way to keep that link stays visible. This means someone can click the link repeatedly. The link resides in a plugin that is in the parent page, and inherited to the child page. How can I get the link to always work, as soon as the plugin is inherited to the child page?

For example, I have www.my.site/en/parent/ and www.my.site/en/parent/child. If a plugin in /parent has a link href="child", then when inherited, on the child page it will say the same thing, making a link that goes to www.my.site/en/parent/child/child, which does not exist.

I experimented with <base href="www.my.site"> and other urls, and with trying to figure out how to reference the current language in the CMS, both without avail. The multilingual middleware seems to take too much control to let the base href work (it rewrites things). Also, you can't have {% xxx %} or {{ yyy }} inside the html in the CMS, which means I don't know how to reference an absolute path that keeps the correct language.

Was it helpful?

Solution

Figured it out. So here's the deal. In the (parent's) plugin, I originally was using the format href="child". href="/child" didn't work at all, since it made a link to www.my.site/en/child. I should have paid better attention to what that failure looks like. After the first slash, it assumes you are starting at just after the language choice - this means you do have access to an 'absolute' path.

So the correct way of writing this was simply href="/parent/child". Sometimes the simple solutions are a bit hard to see. Short breaks can do wonders.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top