質問

Overview

When creating a custom Google Maps map on your site, you are required to include Google's API library which is hosted on their servers.

In order to keep things as speedy as possible I use conditional rules to include various scripts on pages depending on what's needed.

In the process of this, I fear I may have discovered a bug with Diazo, although if I am wrong please let me know.

NOTE: I have filed a bug report already. I just thought I'd ask here incase anyone has had a similar experience and is aware of a work around or fix to the problem.

The problem

When you include an src that isn't local it seems to break my Diazo rules file, thus the Plone site renders the default SunBurst theme instead of my custom Diazo one.

The rule that is breaking everything is as follows:

<rules css:if-content="#map">
 <append theme="/html/body">
   <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=XXXX&sensor=false"></script>
 </append>
</rules>

I have tried removing the https: from the rule, leaving just http:, I have also tried removing it completely just leaving the two slashes. Neither of that has worked. I have other scripts contained within that rule and when I comment out the above <script> tag, it works and they are loaded in fine.

Work around

I am aware I could simply give the script an ID, add it to my HTML template and use my rules.xml to drop it unless my rule is met, but I would rather have Diazo add the script if it was needed instead of dropping it each time the page is served.

Any ideas why this external <script> src= attribute is giving me such aggro?

Thanks!

役に立ちましたか?

解決

I think your file isn't a 100% valid XML (eg.: by including a URL which contains an ampersand).

Try to check it in a validator.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top