I'm working on a small website and need to display blocks of static text on the front page. These blocks will be styled later as paragraphs or bullets and so on.
Where do you suggest I store this text? Do they go as variable in each view where they are used? I could do that, but I'd prefer to have a central location for all this text.
At the moment, the site is very small and hasn't needed to be database driven but that will likely change so I don't mind using the database for storage if that's a better practice. Though I think storing in the database will make it harder to edit the text from my IDE.
I'm guessing the MVC structure Zend uses thought of a solution for this already
If your blocks of static text will be always the same and there won't be any new texts generated dynamically, then you could make use of partials in Zend.
store all of your little texts as partials. In your view script you'll have:
echo $this->partial('partial01.phtml',array('somedata'=>'if you need it'));
You just need to have the partial01.phtml file and any other you need in the views/scripts directory.
Sounds like the key points are:
So, maybe an XML file? It can optionally assign id to each atomic text-chunk. Then you can write a class that reads the XML file and offers an interface like getAll()
, getById($id)
. This gets you the raw data which you can then style however you want - into a bunch of <p>'s, <li>'s, etc.
SimpleXML is pretty easy to work with.