PHP newbie (generating HTML content in a generic way)- HOW ?

This is a discussion on PHP newbie (generating HTML content in a generic way)- HOW ? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; On Apr 11, 6:23*pm, Jerry Stuckle <jstuck...@attglobal.net> wrote: > kenoli wrote: > > On ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 04-12-2008
kenoli
 
Posts: n/a
Default Re: PHP newbie (generating HTML content in a generic way)- HOW ?

On Apr 11, 6:23*pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> kenoli wrote:
> > On Apr 11, 8:40 am, "Álvaro G. Vicario"
> > <webmasterNOSPAMTHA...@demogracia.com> wrote:
> >> *** Ronald Raygun escribió/wrote (Thu, 10 Apr 2008 22:45:17 +0100):

>
> >>> Thanks Álvaro, this looks like EXACTLY what I was looking for. By the
> >>> way, what is the codigo() function used for ? (is it a spanish word ora
> >>> PHP keyword)?
> >> It's a custom function I use in the site the sample comes from. I just
> >> forgot to remove it <:-)

>
> >> --
> >> --http://alvaro.es-Álvaro G. Vicario - Burgos, Spain
> >> -- Mi sitio sobre programación web:http://bits.demogracia.com
> >> -- Mi web de humor en cubitos:http://www.demogracia.com
> >> --

>
> *> I do something similar. *In addition, you can create functions and
> *> call them at various points in the page to insert content of all sorts
> *> along with appropriate html and tags, style attributes and
> *> javascript. *Using a master function with a switch operator, you can
> *> vary the template, location of content in the page and other
> *> variables. *I actually found it was easier to set this up myself than
> *> to learn Smarty, which looked like a challenge.
> *>
> *> I'm really happy with what I have and can customize it to do exactly
> *> what I want it to do.
> *>
> *> --Kenoli
> *>
>
> (Top posting fixed)
>
> Much better than using a switch() function is to use classes - or
> different functions to do different things. *Never have one function do
> multiple things - like output different HTML based on a switch()
> statement. *It makes troubleshooting a nightmare.
>
> P.S. Please don't top post. *Thanks.
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================


The usefulness of the switch operator for me is that based on a
particular field or combination of fields in a record it can select a
specific template, a specific page placement in a template, a
particular navigation function, data from a particular related table,
etc. As far as I can see, to do this kind of thing is going to
require some kind of conditional operator to select the appropriate
templates and functions and it seemed efficient to me to have it all
taken place in one location using a switch, and pretty easy to debug.
I'd be interested knowing more about the downside of this and
alternative constructs. Even using a class would require some kind of
switch like conditional within the class.

The way I am doing this is to send a get query to a php script in a
file that sets a series of variables based on what it receives
triggering a switch that selects the right template and functions
based on what it receives. It seemed pretty efficient and elegant to
me, though I am flying by the seat of my pants and a lot of non-
programmer intuition. I essentially have one script creating all the
pages in my site by connecting data through a set of functions applied
to a set of templates.

--Kenoli
Reply With Quote
  #12 (permalink)  
Old 04-12-2008
Jerry Stuckle
 
Posts: n/a
Default Re: PHP newbie (generating HTML content in a generic way)- HOW ?

kenoli wrote:
> On Apr 11, 6:23 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> kenoli wrote:
>>> On Apr 11, 8:40 am, "Álvaro G. Vicario"
>>> <webmasterNOSPAMTHA...@demogracia.com> wrote:
>>>> *** Ronald Raygun escribió/wrote (Thu, 10 Apr 2008 22:45:17 +0100):
>>>>> Thanks Álvaro, this looks like EXACTLY what I was looking for. By the
>>>>> way, what is the codigo() function used for ? (is it a spanish word or a
>>>>> PHP keyword)?
>>>> It's a custom function I use in the site the sample comes from. I just
>>>> forgot to remove it <:-)
>>>> --
>>>> --http://alvaro.es-Álvaro G. Vicario - Burgos, Spain
>>>> -- Mi sitio sobre programación web:http://bits.demogracia.com
>>>> -- Mi web de humor en cubitos:http://www.demogracia.com
>>>> --
>> > I do something similar. In addition, you can create functions and
>> > call them at various points in the page to insert content of all sorts
>> > along with appropriate html and tags, style attributes and
>> > javascript. Using a master function with a switch operator, you can
>> > vary the template, location of content in the page and other
>> > variables. I actually found it was easier to set this up myself than
>> > to learn Smarty, which looked like a challenge.
>> >
>> > I'm really happy with what I have and can customize it to do exactly
>> > what I want it to do.
>> >
>> > --Kenoli
>> >

>>
>> (Top posting fixed)
>>
>> Much better than using a switch() function is to use classes - or
>> different functions to do different things. Never have one function do
>> multiple things - like output different HTML based on a switch()
>> statement. It makes troubleshooting a nightmare.
>>
>> P.S. Please don't top post. Thanks.
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================

>
> The usefulness of the switch operator for me is that based on a
> particular field or combination of fields in a record it can select a
> specific template, a specific page placement in a template, a
> particular navigation function, data from a particular related table,
> etc. As far as I can see, to do this kind of thing is going to
> require some kind of conditional operator to select the appropriate
> templates and functions and it seemed efficient to me to have it all
> taken place in one location using a switch, and pretty easy to debug.
> I'd be interested knowing more about the downside of this and
> alternative constructs. Even using a class would require some kind of
> switch like conditional within the class.
>
> The way I am doing this is to send a get query to a php script in a
> file that sets a series of variables based on what it receives
> triggering a switch that selects the right template and functions
> based on what it receives. It seemed pretty efficient and elegant to
> me, though I am flying by the seat of my pants and a lot of non-
> programmer intuition. I essentially have one script creating all the
> pages in my site by connecting data through a set of functions applied
> to a set of templates.
>
> --Kenoli
>


Which means anytime you need to add a new value or combination of
values, you need to redo your code. Data should never drive code.

But I'm not going to get into an argument with you as to why it's a bad
design. It sounds like you already have your mind made up.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:21 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0