Welcome Guest, Not a member yet? Register   Sign In
Long, static text (not from DB) - Model, View or Controller?
#1

[eluser]dsentker[/eluser]
Hi again,

another "noob" question, i need this for my consideration.

If i want to display, for example, a lot of news entrys, i allocate the Model to get the Entrys from Database, and the Controller will send it to a view i created. But what is to do if there is a long, static text - for example, a few paragraphs in a "about me" page? This text is a static text, where is no important or frequently need to change it later, constisting of three or four paragraphs (<p>'s and </p>'s). Additionally, a DB-based (MySQL etc) content-source is not that what i would use for a small website.

Idea 1:
I will put the static long text directly into the view file. Disadvantage: I want to use the view files as general wireframes: Instead of a use of many view files (aboutme-view.php, contactus-view.php, learnmore-view.php etc.) i want to use only a few view files (two_columns-view.php, main_with_banner-view.php etc.). If i add text to the view files, i cant use this view for another Controller. I hope my compunction is understandable..

Idea 2:
I will insert the static text in XML Files. Now i can load this content with the Model (right?) and put it into any view i like. This is my favourite idea, but is it right?

Idea 3:
I can write the text directly as a variable into a controller i like. Disadvantage: The Text will be hard to maintain. Additionally, it will be annoying and poor to escape all special chars and quotes in a paragraph for the use in a PHP variable.

So what i can do? Is my Idea Nr. 2 the right? Or am i wrong?
#2

[eluser]Jonas G[/eluser]
i feel static text belongs in view files.

I use Colin William's Template Library (http://www.williamsconcepts.com/ci/codei...plate/?v14) which fits my needs perfectly.
#3

[eluser]developer10[/eluser]
[quote author="Jonas G" date="1262058552"]i feel static text belongs in view files.

I use Colin William's Template Library (http://www.williamsconcepts.com/ci/codei...plate/?v14) which fits my needs perfectly.[/quote]

may i ask if you're using the latest (1.7.2.) version of CI? i plan to use Template as well, but first i'd like to know if there are any issues with the latest version
thanks!
#4

[eluser]Jonas G[/eluser]
i am using 1.7.2 and have not had any problems
#5

[eluser]developer10[/eluser]
[quote author="Jonas G" date="1262060938"]i am using 1.7.2 and have not had any problems[/quote]

thanks for the info - i'm about to start implementing it!
#6

[eluser]Colin Williams[/eluser]
I'd go with idea number 2. Models can interact with data in anyway, be it web services, databases, flat files, etc.
#7

[eluser]n0xie[/eluser]
[quote author="dsentker" date="1262056413"]Additionally, a DB-based (MySQL etc) content-source is not that what i would use for a small website.
[/quote]
Why not?

DB's are cheap, since storage is cheap. If the data won't change a lot but does change (say once a year), it's much easier to just have all the data in the database. If you ever need to add or edit a page, it's easy to build CMS like functionality.

If you are concerned about performance, CI has a nice output caching library which saves the entire page as if it were a static page (which is exactly what you want). Set it to never expire and you basically have a static website, but with the benefits of adding a CMS if you so please.
#8

[eluser]dsentker[/eluser]
Sorry for your Answers. A Database is my personally choice, but my boss has a webhoster which provides php, but no database (yes, in germany there are still webhosters with that bad combination Sad )
#9

[eluser]2think[/eluser]
Hi dsentker,

If your boss/employer's webhost does not provide a database, then one of the agenda items for 2010 may be to research a new host - merely a suggestion.

In the meantime, if you can't get SQlite to use but your boss may pay for cloud storage, you could try Amazon S3 and their other offerings. The reason I mention that is because a friend has begun using it via PHP (don't think Codeigniter though) in Europe and received a price drop.

Coming from a Java and C background, I have to agree with n0xie that database storage makes a great deal of sense from the beginning, especially when thinking about something like a CMS.




Theme © iAndrew 2016 - Forum software by © MyBB