Nestor A Diaz | 1 Feb 19:10
Gravatar

Escape PHP tags '<? ?>' on HTML Comments <!-- //-->

Hello, i am not sure if this is the supposed behaviour, but suppose i have the following code inside a template.

<!--
<?xml version="1.0" encoding="utf-8"?>
//-->

It will render as is, so having a problem regarding the generated PHP code because the <? ?>

Parse error: syntax error, unexpected T_STRING in ...

but since tal expessions are *not* evaluated inside comments i can't process it with a tal expression.

Shouldn't be the right behaviour to escape such characters when they are inside an html comment ?

I was thinking on implementing something like this on phptal for such case:

echo <<<uuid
<!--
<? blah blah ?>
//-->
uuid;

Waiting for comments ...

Slds.

-- Nestor A. Diaz Ingeniero de Sistemas Tel. +57 1-485-3020 x 211 Cel. +57 316-227-3593 Tel. SIP: sip:211-NS/jz+eG3AXzfdHfmsDf5w@public.gmane.org Email/MSN: nestor-NS/jz+eG3AXzfdHfmsDf5w@public.gmane.org http://www.tiendalinux.com/ Bogota, Colombia
_______________________________________________
PHPTAL mailing list
PHPTAL@...
http://lists.motion-twin.com/mailman/listinfo/phptal
romtek | 4 Dec 19:06
Picon

Documentation needs updating about tal:on-error

>From the current description, it's not clear that if a specified macro isn't found, an exception could be suppressed too. I had to find this out by running an experiment. So, I think the documentation should be updated.

<tal:block metal:use-macro="${macroFileName}/pageSpecificHeadPlaceholder" tal:on-error=""></tal:block>

I've picked up this trick from ASPX files I've recently had to maintain. This allows me to specify page specific additions to the head section within page macros.

_______________________________________________
PHPTAL mailing list
PHPTAL@...
http://lists.motion-twin.com/mailman/listinfo/phptal
Anton Andriyevskyy | 24 Nov 22:10
Picon
Gravatar

HTML5 - requires <link> to be closed

Hi.


I'm using html5boilerplate and it generates and inserts <link ...> in my html automatically.
The <link> is not self-closed, nor followed by </link>.

Here is my code:

return $tal
->setTemplateRepository(array(ROOT_PATH.'view'))
->setOutputMode(PHPTAL::HTML5)
->setTemplate('template.html')
->set('page', $page)
->execute();

I get this exception:
Tag closure mismatch, expected < /link > (opened in line 24) but found < /head >

... but HTML5 does not require <link> to be closed.

So how to deal, any ideas?

Anton Andriyevskyy
Business Automation & Web Development

_______________________________________________
PHPTAL mailing list
PHPTAL@...
http://lists.motion-twin.com/mailman/listinfo/phptal
Picon
Gravatar

PHPTAL Zend Framework 2

Hi,

Since Zend Framework 2 has its Zend_View class changed to some 
PhpRenderer, ZTal class from Namesco is not compatible anymore.

Have any of you developers here tried to connect TAL to ZF2 already? Any 
idea how to do it best according to ZF2 patterns?

Thanks,
Piotrek

-- 

E-mail +48 501–235–929

Website piotrek.rybaltowski.pl <http://piotrek.rybaltowski.pl/>

Skype prybaltowski

LinkedIn <https://www.linkedin.com/in/prybaltowski> GoldenLine.pl 
<http://www.goldenline.pl/piotrek-rybaltowski> Facebook 
<https://www.facebook.com/dekoderek> Twitter 
<https://twitter.com/dekoderek>

_______________________________________________
PHPTAL mailing list
PHPTAL@...
http://lists.motion-twin.com/mailman/listinfo/phptal
romtek | 3 Nov 09:00
Picon

Paths to resources in templates

Hi,

The nature of the development approach that I use is that paths to resources (images, CSS and JS files, etc.) relative to the template files during design time are different from those during run time. (I have templates in a separate folder, but my web app runs as index.php in the root folder.)

I like to see preview of a page I work on in Design view of Expression Web or Dreamweaver, and so in order to have images, etc. point to proper paths during design time and also during run time, I do something like this in my templates:

<img tal:attributes="src string:${resourcesDir}/shared/images/menu_bar.jpg" src="../../resources/shared/images/menu_bar.jpg" />

This increases workload, makes code less readable, and is error prone during modifications.

How do you, guys, deal with this issue, if you do? Maybe there's a trick that I haven't thought of. I've tried using <base> element, but Dreamweaver ignores it, and Expression Web messes up my code. By the way, this problem isn't limited to those who use PHPTAL but, apparently, is also shared by some of those who Code Igniter (and, I am sure, other frameworks that require a structure of folders): http://codeigniter.com/forums/viewthread/94591/#478998

Roman

_______________________________________________
PHPTAL mailing list
PHPTAL@...
http://lists.motion-twin.com/mailman/listinfo/phptal
Ježísheck | 2 Nov 13:30
Picon
Gravatar

Translation sometimes works sometimes don't

Hi fellow PHPTALers!


I'm experiencing strange thing with translations.
I have a simple template index.pt:

<metal:page metal:use-macro="main_template.pt/page">
  <metal:content metal:fill-slot="content">

    <h1 i18n:translate="">H1 for testing</h1>
    
    <p tal:content="authUser/isAdmin">dummy</p>

    
  </metal:content>
</metal:page>

and it works fine sometimes. I mean in some cases it properly translates itself according to photoblog.po:

msgid ""
msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"

msgid "H1 for testing"
msgstr "Jednoduchá věta v češtině"

This photoblog.po is correctly converted to photoblog.mo. But the translation appears to take place only about few seconds when I make some changes to photoblog.po and regerate the .MO file. And then again after a while when no request comes. I guess this will have something to do with caching, but have no idea how. I also do regeneration of .MO files with every request for the development stage by calling the shell script doing that and that script works fine too. Any ideas?

PHPTAL 1.2.2, PHP 5.3.3, Ubuntu Server 10.10

Jezisheck


_______________________________________________
PHPTAL mailing list
PHPTAL@...
http://lists.motion-twin.com/mailman/listinfo/phptal
GRolf | 21 Oct 21:59

nested UL


I have a multilevel array, where, as the template concerns, the number 
of levels is unlimited.

eg
$objects = array('Food'=>array('Fruit'=>array('Red'=>array('Cherry', 
'Strawberry'), 'Yellow'=>array('Banana')), 'Meat'=>array('Steak', 
'Hamburger'));

I'd like to loop through this array in my templates and end up with

<ul>
<li>Food
   <ul><li>Fruit
     <ul><li>Red
       <ul><li>Cherre</li><li>Strawberry</li></ul>
     </li><li>Yellow
... etc

How could I do this, without needing to know the number of levels?

--

-- 

GRolf
Bas Kooij | 26 Sep 16:06
Picon

Cleaning cache files

Hi,

I make use of tal:cache attributes for an e-commerce 
website. The cache expression for a block element 
containing product info looks like this: 

30d per php:product.GetProductId() . languageCode . productsLastUpdate

Obviously, if language or productId changes I want to 
keep the cache files. But, if the variable productsLastUpdate 
changes all cached files for this block become obsolete. 
Is there any way to delete the files that were cached using this 
identifier? Or do I just have to wait 30 days for the cache to 
be cleared automatically.

Regards,
Bas Kooij
Teis Lindemark | 23 Sep 20:16

tal:condition question

Hi,

I have a list in my application where the first column should be one 
icon if the id of the offer is in an array or another icon otherwise. 
The array that have some icons looks something like this: $tmp[id] = 1 or 0.

If id is 1, I should have one icon and another if 0. I added the array 
to template like this: $template->tmp = $tmp; and then I tried to do this:
<td tal:condition="tmp/${offers/idiffer}">....</td> Where offers/idoffer 
is the list that is repeated in the table, so each row have one idoffer.

Do anyone have any suggestion how I can fix this?

Hope you understand my problem.

Cheers,

Teis
Tarjei Huse | 1 Sep 15:56
Gravatar

Escaping ${} and $

Hi, I'm trying to include a JQuery template containing ${} into a PHPTal
template. Is there a way to say "do not use phptal within this block" or
just escape the $ signs?

--

-- 
Regards
Tarjei Huse
Tjerk Meesters | 26 Aug 09:49
Picon

tales eq: modifier

Hi guys,

Wrote this modifier to solve a small inconvenience with conditional
blocks; this time I had five different blocks and I didn't feel like
passing five variables to control them.

Hope it's useful to you guys ;-)

The syntax:
"eq:" [ " " expr ]*

These are some examples:

eq: data/value string:3
    Compares data/value with "3"

eq: data/value string:3 data/value2 string:5
    Compares data/value with "3" and data/value2 with "5"

eq: data/value data/value2 string:6
    Compares both data/value and data/value2 with "6"

One caveat: due to the simplistic parsing I'm doing you can't have
spaces in the string: literals.
Another one: it uses closures, so it would break in < 5.3.0

Here's the function:
function phptal_tales_eq($src, $nothrow)
{
	return join('&&', array_map(function($chunk) {
		static $last = false;

		if (!isset($chunk[1])) {
			$chunk[1] = $last;
		} elseif ($last === false) {
			$last = $chunk[1];
		}

		return join('==', $chunk);
	}, array_chunk(array_map(function($path) use ($nothrow) {
		return phptal_tales($path, $nothrow);
	}, explode(' ', trim($src))), 2)));
}

--

-- 
--
Tjerk

Gmane