weixin_39987211
2020-12-29 13:47 阅读 0

CE Hyperlink

Hi,

the CE Hyperlink provides the posibility to select an own template (contao 3.3.2). But the selection has no impact. I can choose whatever template (even "ce_accordion"), the output is every time the same.

Thanks Dirk

该提问来源于开源项目:contao/core

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

10条回答 默认 最新

  • weixin_39851918 weixin_39851918 2020-12-29 13:47

    What are the steps to reproduce the issue?

    点赞 评论 复制链接分享
  • weixin_39699746 weixin_39699746 2020-12-29 13:47

    Simply choose a foreign template in the demo on the hyperlink demo element. Just tested in the online demo Contao 3.3.3. Everything ok there.

    点赞 评论 复制链接分享
  • weixin_39987211 weixin_39987211 2020-12-29 13:47

    The original issue was, I want to have a hyperlink with image and text. The CE hyperlink provides me to add an image. But when I add the image no text wil be displayed. The parameter "Alternate Text", "Title" and "Caption" wouldn't really help.

    Then I discovered the "Template" Parameter. So I created my own template "ce_hyperlink_my". It will even displayed in the select-box. But when I choose the template, nothing happens. The image will still displayed without any changes I have made to the template. Even when I choose another template like "ce_accordion" nothing happens. Still the html dom is the same.

    I'm using contao 3.3.2

    : in the online demo I have only made a text link. When I choose another template like "html" the link will disapear. That should be correct (but imho useless). In the online demo I'm not able to make another template because this backend module is missing.

    点赞 评论 复制链接分享
  • weixin_39987211 weixin_39987211 2020-12-29 13:47

    OK, I have found the problem. When I just use text link, then the template will work. When I add the image, the template will not work.

    点赞 评论 复制链接分享
  • weixin_39638708 weixin_39638708 2020-12-29 13:47

    https://github.com/contao/core/blob/master/system/modules/core/elements/ContentHyperlink.php#L75

    This should check if strTemplate equals the default template or if a custom template is chosen before replacing it with ce_hyperlink_image

    点赞 评论 复制链接分享
  • weixin_39851918 weixin_39851918 2020-12-29 13:47

    This is a known limitation of the new feature. It also applies to the login module, which uses different templates based on the module settings (e.g. mod_login_1cl or mod_login_2cl). It is not possible to dynamically overwrite these templates.

    点赞 评论 复制链接分享
  • weixin_39936792 weixin_39936792 2020-12-29 13:47

    I just stumbled upon this issue too, while trying to override the hyperlink element template. I think this particular case can easily be solved by not using two templates for hyperlinks, because the image settings can easily be integrated into the default hyperlink part.

    I can create a pull request if you'd prefer that.

    点赞 评论 复制链接分享
  • weixin_39851918 weixin_39851918 2020-12-29 13:47

    Yes, basically I do. However I'm not sure which branch to use as target. The feature implies a BC break, so it will only be added to Contao 4.

    点赞 评论 复制链接分享
  • weixin_39936792 weixin_39936792 2020-12-29 13:47

    I know… we could add a check for a custom ce_hyperlink_image template, but that could still conflict with a custom ce_hyperlink template but not …image

    点赞 评论 复制链接分享
  • weixin_39997194 weixin_39997194 2020-12-29 13:47

    This problem also occurs with the LTS-version (3.2.19) though you are not able to choose another template there. So in this case it's imho a real bug (at least for the LTS).

    Same like described: If you use hyperlink with a linktext, the template works. If you use hyperlink with an image, changes in the template don't work.

    点赞 评论 复制链接分享

相关推荐