Dynamic Variables/Content
Permalink
We have a store that has software information stored in it. I made sure that I kept it in the same database as Concrete so that I can easily access the information.
What do you think the best method would be to insert dynamic variables into a content page? For example:
Fictitious Software 1.0.2 Download (2M)
I would like to be able to add certain variables so that it pulls version information, download location etc from the database before it displays it to the user.
What would be the best method of doing this?
What do you think the best method would be to insert dynamic variables into a content page? For example:
Fictitious Software 1.0.2 Download (2M)
I would like to be able to add certain variables so that it pulls version information, download location etc from the database before it displays it to the user.
What would be the best method of doing this?
Right now I am editing the controller.php page in the content block and doing a complicated string_replace on the content. Is there a better way of doing this, besides overriding the default block/content/controller.php?
yeah that sounds really wrong. it sounds to me that you should make a new custom block type for your content needs, either that or a single page to deal with your completely unique instance.
heh I was afraid you would say that :)
For example:
http://www.plumamazing.com/index.php?cID=159...
The part where it shows download link and version number.. it is a regular content block, but just certain items within the block need to be swapped out.
So basically in the content block they can put something like [[iwatermark download]] and it would then replace that with the actual download url for that piece of software. It's working right now. But I figured there might be a better way. Im thinking adding a whole block type though would then confine the download link to one block instead of inline with the content.
For example:
http://www.plumamazing.com/index.php?cID=159...
The part where it shows download link and version number.. it is a regular content block, but just certain items within the block need to be swapped out.
function getContent() { $content = $this->translateFrom($this->content); $content = $this->softwareSwap($content); return $content; }
private function softwareSwap($content) { $content = preg_replace_callback( '/\[\[(.*?)\ (.*?)\]\]/is', array('ContentBlockController', 'getSoftwareInfo'), $content); return $content; }
private function getSoftwareInfo($matches) { require_once 'softwareinfo.php'; if (empty($this->softwareInfo)) $this->softwareInfo = new softwareinfo; return $this->softwareInfo->data[$matches[1]][$matches[2]]; }
So basically in the content block they can put something like [[iwatermark download]] and it would then replace that with the actual download url for that piece of software. It's working right now. But I figured there might be a better way. Im thinking adding a whole block type though would then confine the download link to one block instead of inline with the content.