is this operator exists in ez32 template lang ? (was in smarty tmp)

Author Message

Selmah Maxim

Wednesday 21 May 2003 5:41:02 am

Hi ..

My old site is using Smarty template, and there was an operator to delete the white spaces from the template, i mean the normal when u click view source u got this

<table>
<tr>
<td>
sdcsdcsdcdsccs<br>
balalaajaja <br>

</td>

</tr>

etc ...

with this operator will no space :

<table><tr><td>sdcdscds<br>sdcsd<br></td></tr>

is this operator exists also in ez32 template ?

Jan Borsodi

Wednesday 21 May 2003 5:47:00 am

No, but if you know some PHP you can very easily create it yourself.
Look at lib/eztemplate/classes/eztemplatephpoperator.php for a very simplistic operator, copying this and creating a new operator shouldn't be too difficult.
There might also be some PHP function which can do the whitespace stripping for you.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Selmah Maxim

Wednesday 21 May 2003 7:32:43 am

---------
$tpl->registerOperators( new eZTemplatePHPOperator( array( "upcase" => "strtoupper",
"reverse" => "strrev" ) ) );
------------

nice but where to insert this code ?

what i need maybe not operator , maybe modifier , how to add this function to the template :
{strip}
..
.
.
{/strip}

the php function could be this :

function MakeStrip($str)
{

$match = array();
if (preg_match_all("!{$ldq}strip{$rdq}.*?{$ldq}/strip{$rdq}!s", $str, $match))
{
$strip_tags = $match[0];
$strip_tags_modified = preg_replace("!{$ldq}/?strip{$rdq}|[\t ]+$|^[\t ]+!m", '', $strip_tags);
$strip_tags_modified = preg_replace('![\r\n]+!m', '', $strip_tags_modified);
for ($i = 0; $i < count($strip_tags); $i++)
$template_compiled = preg_replace("!{$ldq}strip{$rdq}.*?{$ldq}/strip{$rdq}!s",
preg_replace('![\\$]\d!', '\\\\\\0',$strip_tags_modified[$i]),
$str, 1);
}

$Str = str_replace("}","",$template_compiled);
return str_replace("{","",$Str);
}

from smarty code!

thx.

Bruce Morrison

Wednesday 21 May 2003 9:06:42 pm

I actually wrote something about this the other day in the Contributed documentation :)
http://ez.no/developer/ez_publish_3/documentation/ez_publish_3/terminology_basics/undocumented_template_functions_and_operators/adding_custom_template_operators_eztemplatephpoperator

You could use this to make the php function 'trim' http://www.php.net/manual/en/function.trim.php availiable in templates (trim only removes whitespace from the begining and end of the text)

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Selmah Maxim

Thursday 22 May 2003 12:51:19 am

no need for trim here, i need to remove the all white parts from the template, becoz some times it make error in the template layout!
i.e
<td><img src=....>
</td>

in this case some times u will get white spaces 1x1 pix under the image !

what i wanna do to add this function to ez temp lang :

{strip}
TEMPALTE content
{/strip}

the function above will replace all the white space in the template, not like trim !

any help ?

Bruce Morrison

Thursday 22 May 2003 3:14:02 pm

I've seen this issue as well and have found that the easier way to get around it is to modify the ezimage.tpl template so that it is all one a single line.

The strip function sounds like a good addition. These doesn't appear that there is a php function that will do this directly.

It is possible to add a template function to ezpublish as an extention. Have a look at the ezRSS contributed module. It basically creates a new template operator as an extention. You could use this to add the strip function.

Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Selmah Maxim

Friday 23 May 2003 3:49:35 am

Hi Bruce ..

make ezimage.tpl one line will do nothing !
try to look at this page source, and i had worte above fucntion (from smarty template) will make no white space in source (\t \r) !

i got no idea from Ezrss since is geting an array from new site !

i think how cann`t get the idea of strip, copy the function above and try it, or download smarty and try it !

Bruce Morrison

Friday 23 May 2003 6:47:18 pm

Hi Selmah

>make ezimage.tpl one line will do nothing !

It will, I know because I have done it :) Basically you need to remove all the unnecessary whitespace and all newlines from ezimage.tpl to ensure that you don't end up with extra padding when the image is rendered in a table.

>try to look at this page source, and i had worte above fucntion (from smarty >template) will make no white space in source (\t \r) !

I understand what you are tring to achieve, editing ezimage.tpl is simply one way of doing it.

> i got no idea from Ezrss since is geting an array from new site !

EzRSS is an example of adding a new template operator as an extention. You should be able to use this to add your strip template. Use the framwork in EzRSS but replace the function that gets the info from the other site with your strip function.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Selmah Maxim

Saturday 24 May 2003 12:38:25 am

Hi Bruce ..

Your idea is right, but i need to remove all the spaces from the template :)

i`ll keep trying with ezrss !

thx anyway !

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 30 2025 21:37:04
Script start
Timing: Jan 30 2025 21:37:04
Module start 'layout'
Timing: Jan 30 2025 21:37:04
Module start 'content'
Timing: Jan 30 2025 21:37:05
Module end 'content'
Timing: Jan 30 2025 21:37:05
Script end

Main resources:

Total runtime1.1231 sec
Peak memory usage8,192.0000 KB
Database Queries77

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0044 588.3906151.2422
Module start 'layout' 0.00440.0030 739.6328220.7500
Module start 'content' 0.00751.1147 960.38284,567.6797
Module end 'content' 1.12220.0009 5,528.062523.7813
Script end 1.1230  5,551.8438 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2929160.0002
Check MTime0.00120.1064160.0001
Mysql Total
Database connection0.00080.072010.0008
Mysqli_queries1.010990.0110770.0131
Looping result0.00080.0731750.0000
Template Total1.073395.620.5366
Template load0.00200.175920.0010
Template processing1.071395.390220.5356
Template load and register function0.00130.117710.0013
states
state_id_array0.00110.097510.0011
state_identifier_array0.00240.212420.0012
Override
Cache load0.00190.16511000.0000
Sytem overhead
Fetch class attribute can translate value0.00170.149530.0006
Fetch class attribute name0.00180.1587110.0002
XML
Image XML parsing0.00110.102230.0004
class_abstraction
Instantiating content class attribute0.00000.0024130.0000
General
dbfile0.00200.1778230.0001
String conversion0.00000.000540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
17content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
12content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 44
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs