Re: templating engine options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 26 May 2009 03:48:41 am Nathan Rixham wrote:
> Sancar Saran wrote:
> > <?php
> > $content = 'No Comments';
> > if(isset($comments) and is_array($comments) and count($comments) > 0 ) {
> > 	$content = '';
> > 	foreach( $comments as $index => $comment ) : $content. = "<a href='".
> > $comment->link."'>".$comment->title."</a>"; endforeach;
> > }
> > ?>
> >
> > <h2>Comments</h2>
> > <div id="comments">
> > 	<?=$content?>
> > </div>
> >
> > index.php
> > ob_start();
> > require('template.php');
> > echo ob_get_clean();
> >
> >
> > I'm still do not understand for complex template system requirement.
>
> I just _need_ the two abstracted.
>
> php must have no html in it
> html template must contain no php
>
> > Why it have to be very complex system.
> >
> > Large data array, some conditions, lots of loops, and What else ?
> >
> > http://www.flytag.de/
> > http://urlaub-finder.de/
> > http://airportdirekt.de/
> >
> > All same system. With different css designs.
>
> yup, did this myself for a longgggg time; here is some very old code I
> used to use!
>
> newCage();
> $content = cage(include $file);
>
> function newCage() {
> 	ob_start();
> }
> function cage() {
> 	$includeOutput = ob_get_contents();
> 	ob_end_clean();
> 	return $includeOutput;
> }
>
> lol
Alright, my vote going to smarty.

After compilation, it running on native php.

And

When we use TYPO3 native marker model (which fits your requirement, no php in 
template) I found very dull. Load template to memory, fetch part of template, 
generate loop for processing template, feed template keys in the loop. 

After some time %75 of code become template feed. Like this

//--- Get Template
$this->templateFileContent = $this->cObj-
>fileResource('fileadmin/templates/travelit_booking.html');
$strCarLoop                = $this->cObj->getSubpart($this-
>templateFileContent,"###CAR_LOOP###");
$strPLoop                  = $this->cObj->getSubpart($this-
>templateFileContent,"###PASSANGER_LOOP###");
$strCarTable               = $this->cObj->getSubpart($this-
>templateFileContent,"###CAR_TABLE###");
$strHotelBooking           = $this->cObj->getSubpart($this-
>templateFileContent,"###HOTEL_BOOKING###");
$strFlightBooking          = $this->cObj->getSubpart($this-
>templateFileContent,"###FLIGHT_BOOKING###");

....

if(isset($arrData['MW']) && is_array($arrData['MW']['MWLIST']['CAR']))
{
	$intCarSize = sizeof($arrData['MW']['MWLIST']['CAR']);
	for($intX=0;$intX < $intCarSize;$intX++)
	{
		$arrSubst = '';
		$arrSubst['###CAR_OPTION_VALUE###'] = $arrData['MW']['MWLIST']['CAR'][$intX]
["@"]['GROUP']."-".$arrData['MW']['MWLIST']['CAR'][$intX]["@"]['ID1']."-".
$arrData['MW']['MWLIST']['CAR'][$intX]["@"]['ID2']."-".$arrData['MW']
['MWLIST']['CAR'][$intX]["@"]['NAME']."-".$arrData['MW']['MWLIST']['CAR']
[$intX]["@"]['PRICE'];
		$arrSubst['###CAR_OPTION_PRICE###'] = number_format($arrData['MW']['MWLIST']
['CAR'][$intX]["@"]['PRICE'], 0, ',', '.');
		$arrSubst['###CAR_OPTION_NAME###']  = $arrData['MW']['MWLIST']['CAR'][$intX]
["@"]['NAME'];
		$strCarss.= $this->cObj->substituteMarkerArrayCached($strCarLoop,$arrSubst);
	}
}

<!-- ###CAR_LOOP### begin -->
			<option value='###CAR_OPTION_VALUE###' 
>&nbsp;###CAR_OPTION_PRICE####&nbsp;&euro;&nbsp;###CAR_OPTION_NAME###</option>
<!-- ###CAR_LOOP### end -->

<!-- ###CAR_TABLE### begin -->
			<tr>
				<td  colspan='5' style='text-align:center; font-size:14px;'>
					###BOOKING_RENT_A_CAR_LABEL###
				</td>
			</tr>
			<tr>
				<td colspan='2'>
						<center>###BOOKING_RENT_A_CAR_INFO###</center>
						<br/><br/>
						<center><a href='#' 
onClick='Open_Window("http://www.sunnycars.com/b2c.docs/deu.l/single_vehicledetails.html?"+getCarUrl(),"SUNNY","scrollbar=yes",800,600)'><img 
src='/fileadmin/templates/img/scar.gif' border='0' />
						<br/><br/>###BOOKING_CAR_INFO_LABEL###</a></center>
				</td>
				<td colspan='4'>
						<select name='MWTYP' size='10' >
							<option value='-'>###BOOKING_I_DONT_WANT_TO_RENT_A_CAR###</option>
							###BOOKING_RENT_A_CAR_LOOP###
						</select>
				</td>
			</tr>
<!-- ###CAR_TABLE### end -->

Then I realize, doing some coding for data which I already have make me sick. 
and When you go with multi language site you will realize, every tiny bit of 
template have to template marker keys. And you have to do this mule job

And begin to use this.

<table border='0' cellpadding='0' cellspacing='0' class='dtable rbook-renta-
car'><tbody>
	<tr>
		<td class='rbook-element-label'><input type='radio' name='car_rental' 
value='no' checked='checked' onclick='toggle_carrental("disabled")' 
/>&nbsp;<?=evo::$lang['_i_dont_want_to_rent_a_car_'];?></td>
		<td>&nbsp;</td></tr>
	<tr>
		<td class='rbook-element-label'><input type='radio' name='car_rental' 
value='yes' onclick='toggle_carrental("enabled")' />&nbsp;<?=evo::
$lang['_i_want_to_rent_a_car_'];?></td>
		<td >&nbsp;</td></tr>
	<tr>
		<td class='rbook-rentacar-picture'>
			<img src='http://www.sunnycars.de/item/img_photo13.jpg?lid=deu' width='80%' 
height='80%' alt='image'/>
			<br/>
			<a href='javascript:void(0);' class='cResponseCarInfo'><?=evo::
$lang['_car_info_'];?></a>
			</td>
		<td class='rbook-rentacar-cars'>
			<select name='car_list' id='car_list' size='10' class='ui-corner-all' 
onchange='updatePrice("rentacar","","");' disabled='disabled'><?=$this-
>get_rentacar($this->php_response['MW']['MWLIST']['CAR'])?></select>
			<div class='page_br'>&nbsp;</div>
		</td></tr>
	</tbody></table>
</div>

(both of them doing same thing, second one had extended js.)

And no html in PHP was your code ability.  I had %5 percent html in my php 
code because making them separate file was unnecessary (to me) and all of them 
non themeable management markup.

Anyhow, in these days I'm trying to fit my code into jQuery's CSS framework. 
After one year usage of inline php template system. We almost forgot the 
templates. Most time consuming was Configuring TYPO3 and arrange CSS.

Regards

Sancar

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux