For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > September 2004 > Re: [SMARTY] includes









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] includes
Monte Ohrt

2004-09-02, 4:01 pm

{if $report_type ne ""}
{include file="reports.$report_type.inc.html"}
{/if}

pete M wrote:

> is there a more elegant way to code below..The variable companed is
> also tpart of the file name
>
> {if $report_type == 'general'}
> {include file="reports.general.inc.html"}
>
> {elseif $report_type == 'ppm'}
> {include file="reports.ppm.inc.html"}
>
> {elseif $report_type == 'finance'}
> {include file="reports.finance.inc.html"}
>
> {elseif $report_type == 'testing'}
> {include file="reports.testing.inc.html"}
> {/if}
>

Boots

2004-09-03, 3:58 am

--- Monte Ohrt <monte@ispi.net> wrote:
> {if strstr($report_type ne ""}
> {include file="reports.$report_type.inc.html"}
> {/if}


Hmm. It seems to me that he wants to do two things: check $report_type
against a range and if it is valid, then include a report. I would
might do something like:

> {if strpos("general||ppm||finance||testing||", "`$report_type`||")}
> {include file="reports.$report_type.inc.html"}
> {/if}


Still, it seems more reasonable that this can be handled in the PHP
controller.

xo boots

> pete M wrote:
>

Messju Mohr

2004-09-03, 3:58 am

On Thu, Sep 02, 2004 at 04:26:54PM -0700, boots wrote:
> --- Monte Ohrt <monte@ispi.net> wrote:
>
> Hmm. It seems to me that he wants to do two things: check $report_type
> against a range and if it is valid, then include a report. I would
> might do something like:
>
>
> Still, it seems more reasonable that this can be handled in the PHP
> controller.


i'd really do that in the php controller.

either sign a contract that you will always and ever have a resonable
value assinged to $report_type, or usr a default_template_handler_func
to provide a reasonable fallback if "reports.$report_type.inc.html"
doesn't exists.

> xo boots
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com