External XML created by Concrete
Permalink
Hi,
I'm building a new block with a XML-based Flash file.
De XML must be an external loaded XML file. I created in the tools directory a phpscript that loads the XML (generated from the database).
The flashfile (in view.php) loads this file.
The code from the view.php
The file that should be loaded is: /blocks/myblock/tools/xml.php?bID=<? echo $this->controller->getBlockID() ?>
The code in xml.php:
When de XML file is loaded, the function BlockType::getByHandle('myblock'); can't be recognized.
Which code should be added so that my function in xml.php will be recognized?
Which require_once, Loaders and modules?
Thank you!
I'm building a new block with a XML-based Flash file.
De XML must be an external loaded XML file. I created in the tools directory a phpscript that loads the XML (generated from the database).
The flashfile (in view.php) loads this file.
The code from the view.php
<script type="text/javascript"> var flashvars = {}; flashvars.xml = "/blocks/myblock/tools/xml.php?bID=<? echo $this->controller->getBlockID() ?>"; flashvars.font = "font.swf"; var attributes = {}; attributes.wmode = "transparent"; attributes.id = "slider"; swfobject.embedSWF("/blocks/myblock/elements/flashfile-1.swf", "flash-container", "900", "360", "9", "/blocks/myblock/elements/flashfile-2.swf", flashvars, attributes); </script>
The file that should be loaded is: /blocks/myblock/tools/xml.php?bID=<? echo $this->controller->getBlockID() ?>
The code in xml.php:
---start of file---- $myblock = BlockType::getByHandle('myblock'); $myblock->controller->bID = $_REQUEST['bID']; $settings = $myblock->controller->build_xml(); echo <?xml.... ... ---end of file---
When de XML file is loaded, the function BlockType::getByHandle('myblock'); can't be recognized.
Which code should be added so that my function in xml.php will be recognized?
Which require_once, Loaders and modules?
Thank you!
It looks like you're calling it directly as a php script. If you call it in another way, it will automatically load the libraries you need, instantiate a database object, etc...
Instead of this:
flashvars.xml = "/blocks/myblock/tools/xml.php?bID=<? echo $this->controller->getBlockID() ?>";
Try this:
And then
flashvars.xml = "<?=$url?>";
That should build a URL like
"index.php/tools/blocks/myblock/xml?bID=12345"
Which will then run your script, but wrapped in concrete, so that it will have access to the block types script, the database, etc...