To avoid this i wrote a little function which you can include and use in your scripts.
I recommend creating a folder common inside your plugins folder and put this in there.
Content.include.js
- Code: Select all
traceln("Include.Content: Start loading Content include")
function Content() {
this.oldContent = ""
this.addContent = ""
this.newContent = ""
}
Content.prototype.add = function(page, add) {
if(!page.extraContent) {
page.extraContent = ""
}
this.oldContent = page.extraContent;
this.addContent = add;
this.newContent = <wrapper></wrapper>;
if (this.oldContent) {
if (this.oldContent.length() > 0) {
if (this.oldContent.wrapper.length() > 0) {
this.newContent.wrapper += this.oldContent.wrapper
} else {
this.newContent.wrapper += this.oldContent
}
}
}
if (this.addContent) {
if (this.addContent.length() > 0) {
if (this.addContent.wrapper.length() > 0) {
this.newContent.wrapper += this.addContent.wrapper
} else {
this.newContent.wrapper += this.addContent
}
}
}
page.extraContent = this.newContent;
return
}
traceln("Include.Content: End loading Content include");
In your plugin first include the file and create a new instance inside your plugin:
- Code: Select all
function YourPlugin(path) {
...
// this plugin resides in plugins/YourPlugin/
include(this.rootPath + "../common/Content.include.js")
this.Content = new Content()
...
}
then use it in onPageCreated event like this:
- Code: Select all
YourPlugin.prototype.onPageCreated = function(page) {
....
var extraContent = <wrapper>
<some nice xml elements/>
</wrapper>;
this.Content.add(page, extraContent);
...
}
... this of course doesn't help if a plugin which doesn't add the content in a propper way gets loaded after your plugins, so i would like to suggest to always take care of this issue when writing plugins which add extraContent.


