Valid point--I was thinking that in a news article or such, the content is
mostly already created and edited, just needed to be posted by someone not
familar with HTML.

I like your idea about the [start-stop block].  To maybe merge what Paul
said with your idea, you could store the name of the function handler
(generates the appropriate content) inside the "[]".

[renderProducts]
[renderImage]
/photos/image1.jpg
[/renderImage]
[renderDescription]
This product will make your skin feel silky smooth.
[/renderDescription]
[renderImage]
/photos/image2.jpg
[/renderImage]
[renderDescription]
New from Nivea, a lotion that moisturizes and protects from the sun.
[/renderDescription]

that way, the main handler (renderProducts) is always at the top.  The main
handler would then strip out the data/sub-routine calls (renderImage,
renderDescription) and pass that data to the function along with a context
variable like $op or something so that the same functions could be used to
display to the screen and to edit the results thanks to $op
(add/modify/view, etc...).  The function renderImage could contain an
internal counter to when to display the next row.  Creating this source data
would require something similar to my last post, except replacing the html
with the appropriate "[]".  Of course, what we are really doing is xml.
Maybe should just do xml:

<renderProducts>
  <product>
    <image>
      /photos/image1.jpg
    </image>
    <description>
      This product will make your skin feel silky smooth.
    </description>
  </product>
  <product>
    <image>
      /photos/image2.jpg
    </image>
    <description>
      New from Nivea, a lotion that moisturizes and protects from the sun.
    </description>
  </product>
</renderInterview>

In parsing the first example, I would probably use preg_match and regular
expressions.  In parsing the xml, I would use php's xml parser.

Hope this helps a little more--
Court

> -----Original Message-----
> From: Monty [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 07, 2002 1:04 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Best way to store/retrieve content??
> 
> 
> Hi Court, thanks a lot for your advice.
> 
> I am fairly new to PHP, so, I'm a little slow in 
> understanding some of the
> suggestions in your detailed post. From what I gather, you 
> suggested that an
> Admin script be created to basically build each portion of an 
> article piece
> by piece, which would then be combined and stored in a single 
> field in the
> Articles data table. Is that right?
> 
> The only thing I can see being a problem with this method is 
> if the writer
> needs to go back and edit the article. Unless I strip out all 
> HTML and parse
> the sections out into individual fields, they would have to 
> contend with all
> the HTML code written into the article content field. I'd 
> like to reduce the
> amount of HTML stored with the article content in the 
> database as much as
> possible so that writers don't have to worry about anything 
> but the most
> basic codes.
> 
> Here's one idea I have. In the database field, the article 
> content may look
> something like this:
> 
> [START-BLOCK]
> [IMG="photos/image1.jpg"]
> This product will make your skin feel silky smooth.
> [END-BLOCK]
> 
> [START-BLOCK]
> [IMG="photos/image2.jpg"]
> New from Nivea, a lotion that moisturizes and protects from the sun.
> [END-BLOCK]
> 
> 
> ...which I can then parse to lay the article out like this...
> 
> 
> +-----------+      +-----------+      +-----------+
> |  image 1  |      |  image 2  |      |  image 3  |
> +-----------+      +-----------+      +-----------+
> 
> Short paragraph    Short paragraph    Short paragraph
> of text under      of text under      of text under
> the image.         the image.         the image.
> 
> +-----------+      +-----------+      +-----------+
> |  image 4  |      |  image 5  |      |  image 6  |
> +-----------+      +-----------+      +-----------+
> 
> Short paragraph    Short paragraph    Short paragraph
> of text under      of text under      of text under
> the image.         the image.         the image.
> 
> 
> If this is a doable and good way to go, then my next question 
> is, which PHP
> string function would be the best to use for parsing custom 
> codes (like
> [IMG=) into actual HTML codes?
> 
> Thanks!
> 
> Monty
> 
> 
> > From: [EMAIL PROTECTED] (Court Shrock)
> > Newsgroups: php.db
> > Date: Thu, 7 Mar 2002 12:16:07 -0800
> > To: 'Monty' <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
> > Subject: RE: [PHP-DB] Best way to store/retrieve content??
> > 
> > Actually, CSS is very powerful--way more than simple html.  
> One drawback is
> > that CSS1 did not include any support for tables directly, 
> but the generic
> > controls work nicely, there just is no way to say "<table 
> align=center>" in
> > CSS1.  A great book that taught me a lot about CSS is
> > http://www.oreilly.com/catalog/css/ --I'd lone it to you if 
> you were local.
> > 
> > I think it would be feasible to store all content in one 
> db: just use your
> > templates to convert the articles to appropriate markup and 
> then store the
> > results.
> > 
> > (I am departing from html)
> > The interview:
> > [input_form]
> > Template: <select>"Interview"</select>
> > Question: <input value="How are you doing?">
> > Answer: <input value="Fine, thanks for asking">
> > 
> > [form_submittal]
> > $content = _header($template);
> > foreach (question) {
> > $content .= "<p class='question'><span 
> class='us'>Us:</span>$question</p>"
> > "<p class='answer'><span
> > class='them'>Them:</span>$answer</p>";
> > }
> > insertArticle($content);
> > 
> > The beauty product:
> > [input_form]
> > Template: <select>"picture"</select>
> > Picture: <input file="pic1.jpg">
> > Description: <textarea>"Just imagine yourself all prettied 
> up like this
> > glorious person"</textarea>
> > 
> > Transition: <textarea>"And now that brings us to some really cool
> > whale-inard products"</textarea>
> > 
> > Picture: <input file="pic2.jpg">
> > Description: <textarea>"We promise that no animals were 
> harmed during the
> > making....."</textarea>
> > 
> > [form_submittal]
> > $content = _header($template);
> > foreach(picture) {
> > $content .= "<p class='picture'><img class='pic$count'
> > src='$file'>$description</p>";
> > if ($transition != '')
> > $content .= "<p class='$transition_count'>$transition</p>";
> > }
> > 
> > 
> > ...anyway, you get the idea.....this is a rather simple 
> approach--but, you
> > could combine something like this with an output template 
> to get really good
> > results.
> > 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to