FW5
I am trying to add the look and feel of my website to a mysql database hosted by same server. Is it best to insert html into the database or load the database within a page generated by FW? If so, how do you proceed. (newbie to FW)
It’s a good idea to try to separate the content (text) from the presentation (layout, color, etc.) if you start putting Web stuff in a database. You CAN certainly put raw HTML in a database record, but it cuts off your options rather dramatically for updating and editing that content later on, and makes it difficult to use the database for sorting and searching if the HTML tags get searched as part of the content as well.
Most dynamic sites are built around a template system, where a page layout is authored in more or less standard HTML, with some placeholders like [[variable_name]] inserted where you want the dynamic content to be inserted. That layout is used as the cookie-cutter by the application server, which turns a request like article.php?id=12345 into the love-child of article.phtml and SELECT * FROM data WHERE id = 12345;.
What you pour into that template, and how detailed your database becomes as a result, depends entirely on how structured your information is to begin with. If you have a news page, where there is a headline, a tease, a pull-quote, a photo, and body text for every single article, then you can put each of those elements in a separate field in the database, leave formatting straight out of it (or use a pidgin HTML like Markdown or Textile to allow minimal inline styling without exposing all the potential dangers of allowing your authors to write code).
At the opposite extreme, you could certainly put an entire page of HTML into a database record, but that’s just a waste of effort.
So take a step back and see what shape you could put it into. There may be a number of different templates, but usually there is an order to things that you can discern and start this process.
I think I understand what you are saying, but not entirely. (novice). I guess I should ask: If I insert an iframe in a freeway generated page with reference to the url of the database, will it display correctly?
If not, to add a simple header (single image) to appear at the top of the page when the database is displayed, how do I do this?
If I insert an iframe in a freeway generated page with reference to the url of the database, will it display correctly?
Simple answer is no!
Firstly a database doesn’t have a url that you can insert.
What you have to do is put code into your FW page that will interrogate the database and display the information that you have requested. You then have to format the output of the database to get it to look right.
Be more specific about what information your database holds and what you want to show on your FW page and we can offer more help.
No, because a database doesn’t do anything Web-like when you access
its URL – it works in a completely different realm.
You will need to use use a programming language like Ruby or PHP or
Perl to access the database using its API (Application Programming
Interface) and issue commands in the database’s native language: SQL
(Structured Query Language). Through the API, the results of that
query will be returned as objects that you will unpack and string
together into HTML using the programming language.
Here’s a very short example, coded in PHP using the MyActiveRecord
database modeling class.
That snippet of code (assuming you also have the MyActiveRecord
library) will select all the records in the cars table that match the
specific query – fewer than 10,000 miles on the odometer) and allow
you to work with each row in the result of that query directly. The
line that begins with ‘print’ simply converts individual properties of
the returned object into HTML text.
Walter
On Feb 5, 2010, at 3:42 PM, Oscar Berlanga wrote:
I think I understand what you are saying, but not entirely.
(novice). I guess I should ask: If I insert an iframe in a freeway
generated page with reference to the url of the database, will it
display correctly?
If not, to add a simple header (single image) to appear at the top
of the page when the database is displayed, how do I do this?
Ok, thank you very much. I have to think about wether to get into programing (lots of studying to do) or to continue just being a designer (sounds more comfortable). I digress, I am going to learn joombla one way or another. Better crack the books. You have been very helpful.