Mathias Jacob | 1 Nov 2008 01:24
Favicon
Gravatar

Re: Re: German translation of the phptal documentation

Hi,

i just got an overview about the german translation and found 2 words. I
think you should use Browser and Code instead of Brauser and Kode. As
far as i know the word Brauser doesn't exists in german and Kode is an
old translation and i don't know anybody who use it.

More later, it's about 2 a.m. in germany and i will get now to sleep.

Mathias

Am Freitag, den 31.10.2008, 23:09 +0100 schrieb Axel Zöllich:
> Hi Moritz,
> 
> > I could help with the translation, e.g. as a corrector, if you give me
> > details about in which way I could contribute. (step-by-step instructions
> > preferred :P) Until the Intrepid release I'll be busy translating the
> > Ubuntu documentation, but afterwards I'll have enough time to assist you
> > and probably correct some mistakes.
> 
> As I've got svn access by now (thanks Kornel) bettest way is for you and me to 
> check out the repository via: 
> svn co https://svn.motion-twin.com/phptal/trunk phptal
> 
> The file in question is phptal/doc/de/book.xml. Integrate your changes an send 
> it to me for merging.
> 
> To update your repository:
> svn update
> 
(Continue reading)

a b | 2 Nov 2008 10:36
Picon
Gravatar

some cache modifications

Hi,

I'm very glad with using phptal:cache, especially with "per " parameter.
But now, I want to achieve something like that:

I have following template:

<div id="word" phptal:cache="1h per url">
            Word of the day is: <span tal:content="word">word of the day</span>
</div>

Now I do:

{{
// :my php code: to retrieve word which takes very long to execute
// returns $word
$tpl=new PHPTAL('test.html');
$tpl->word = $word;
}}

I'd like to execute {{...}} only when cache is not fetched, else just display cached HTML.

I know I have to write trigger like that:
class myTrigger implements PHPTAL_Trigger
        {
            public function start($phptalid, $tpl) {
                $cache_not_fetched = ...
                if ($cache_not_fetched) {
                    {{...}}
                } else {
                    // display cached html
                }
                return self::PROCEED;
            }

            public function end($phptalid, $tpl) {
                return;
            }
        }

But how to detect if cache is fetched by phptal:cache?
Shall I rewrite everything from PHPTAL_Php_Attribute_PHPTAL_Cache to have "per"?

Where I can find PHPTAL_Cache Interface which is mentioned in the manual?

--
regards,
takeshin

_______________________________________________
PHPTAL mailing list
PHPTAL@...
http://lists.motion-twin.com/mailman/listinfo/phptal
Kornel Lesiński | 3 Nov 2008 11:21
Picon
Favicon
Gravatar

Re: some cache modifications

On 02-11-2008 at 09:36:04 a b <admirau@...> wrote:

> I'm very glad with using phptal:cache, especially with "per " parameter.
> But now, I want to achieve something like that:
>
> I have following template:
>
> <div id="word" phptal:cache="1h per url">
>             Word of the day is: <span tal:content="word">word of the
> day</span>
> </div>
>
> Now I do:
>
> {{
> // :my php code: to retrieve word which takes very long to execute
> // returns $word
> $tpl=new PHPTAL('test.html');
> $tpl->word = $word;
> }}
>
> I'd like to execute {{...}} only when cache is not fetched, else just
> display cached HTML.

IMHO the best solution is:

> $tpl=new PHPTAL('test.html');
> $tpl->word = new WordGetter();

> Word of the day is: <span tal:content="word/getWord"/>

Pass to the template an object that is cheap to create and have it do  
heavy work only on demand, e.g. when $word->getWord() is called. If the  
template is cached, the method won't be called.

An even simpler version of the same is:
> <span tal:content="php:word_of_the_day()"/>

--

-- 
regards, Kornel
a b | 3 Nov 2008 19:12
Picon
Gravatar

help


_______________________________________________
PHPTAL mailing list
PHPTAL@...
http://lists.motion-twin.com/mailman/listinfo/phptal
a b | 3 Nov 2008 19:12
Picon
Gravatar

help


_______________________________________________
PHPTAL mailing list
PHPTAL@...
http://lists.motion-twin.com/mailman/listinfo/phptal
takeshin | 3 Nov 2008 19:22
Picon
Gravatar

help

help
end

I'm sorry for those posts,
but I'm trying to get mailman help :)
Christian Welzel | 4 Nov 2008 00:36
Picon
Gravatar

my own keyword handler

Hi there, 

i have written my own keyword handler for phptal which handles the link:
keyword. This worked quite well for simple links but now i want to build 
more complex ones.

I call my handler like this in the simple case:
<a tal:attributes="href link:/*/*/folder">...</a>
The code in the template is this:
Core_Helper_LinkHelper::getInstance()->createUrl('folder',array())
That comes up with a link href="/Module/Controller/folder" which is ok.

Now i want to do this:
<a tal:attributes="href link:/*/*/folder:goto//${ud/id}">
The code in the template should look like that:
Core_Helper_LinkHelper::getInstance()->createUrl('folder',array('goto'=>XXX))
with XXX shall be a function of phptal translating ${ud/id} to the actual 
value.

The important part of my code is this: ($t[1] is the part after the ":")
        $p = explode('//', $t[1]);
        $parameter = 'array(';
        while(($k = array_shift($p)) && ($value = array_shift($p))) {
            $parameter .= ("'".$k."'=>".phptal_tales($value,$nothrow).',');
        }
        $parameter .= ')';
        return 'Core_Helper_LinkHelper::getInstance()->createUrl('.rtrim($params, ',').','.$parameter.')';
But phptal_tales() seems not to be the right function as it generates the line as
this:
Core_Helper_LinkHelper::getInstance()->createUrl('folder',array('goto'=>$ctx->'.phptal_path($ctx->ud
, 'id').',))
which ends in a parser error...

Whats the correct way to implement this?

--

-- 
 MfG, Christian Welzel

  GPG-Key:     http://www.camlann.de/key.asc
  Fingerprint: 4F50 19BF 3346 36A6 CFA9 DBDC C268 6D24 70A1 AD15
Kornel Lesiński | 4 Nov 2008 11:31
Picon
Favicon
Gravatar

Re: my own keyword handler

On 03-11-2008 at 23:36:55 Christian Welzel <gawain@...> wrote:

> But phptal_tales() seems not to be the right function as it generates  
> the line as this:
>
Core_Helper_LinkHelper::getInstance()->createUrl('folder',array('goto'=>$ctx->'.phptal_path($ctx->ud

> , 'id').',))
> which ends in a parser error...
>
> Whats the correct way to implement this?

I think the problem is that you're passing "${ud/id}" as expression to  
phptal_tales(), rather than just "ud/id".

--

-- 
regards, Kornel
Kornel Lesiński | 4 Nov 2008 12:50
Picon
Favicon
Gravatar

Re: my own keyword handler

On 03-11-2008 at 23:36:55 Christian Welzel <gawain@...> wrote:

I've improved parsing of interpolated TALES paths. Please check SVN  
version of PHPTAL and see if that resolves your problem.

--

-- 
regards, Kornel
Christian Welzel | 4 Nov 2008 19:45
Picon
Gravatar

Re: my own keyword handler

Am Dienstag 04 November 2008 schrieb Kornel Lesiński:
> On 03-11-2008 at 23:36:55 Christian Welzel <gawain@...> wrote:
>
> I've improved parsing of interpolated TALES paths. Please check SVN
> version of PHPTAL and see if that resolves your problem.

Ok, now the template compiles fine but it does not, what i want it to do :)

Now it generates
this:
Core_Helper_LinkHelper::getInstance()->createUrl('folder',array('goto'=>$ctx->{phptal_path($ctx->ud, 'id')},))

what leads to the runtime error: Unable to find path 0 in current scope.
"0" is the value of ${ud/id}.

I think, what i want to get
is:
Core_Helper_LinkHelper::getInstance()->createUrl('folder',array('goto'=>phptal_path($ctx->ud, 'id'),))

But i'm not sure, if i'm on the right way.
Yesterday i had another idea: prefix the "value" part with "string:" before feeding it to phptal_tales()
but i didnt have time so far. Will try this soon.

--

-- 
 MfG, Christian Welzel

  GPG-Key:     http://www.camlann.de/key.asc
  Fingerprint: 4F50 19BF 3346 36A6 CFA9 DBDC C268 6D24 70A1 AD15

Gmane