[PHPTAL] PHPTAL: image href

Aaron McClimont amcclimo at chariot.net.au
Wed May 10 17:07:15 CEST 2006


Have a look at Pre and Post filters using the PHPTAL_Filter interface.

Pre-filters would be recommended as the template will be cached with the 
pre-filters applied, where as Post filters are applied with every 
template execution.

As long as the template sits within the web structure, it shouldn't be 
too difficult to create a relative path based on the location of the 
template vs the current url path... and apply that relative path to the 
attributes: src=, img=, href=, etc...

Using a regular expression you should be able to search for these 
occurances with or without spaces, single / double quotes.

I've successfully used this method to create dreamweaver templates which 
i can directly use with PHPTAL, without any modification to paths, and 
avoiding the use of explicit paths or the setting of a base href.

Good luck ;)

dutz dutz wrote:
> Well i just figured that might be the sollution.
> I think there should be some path translation
> implemented in phptal(for href, src etc) at parse
> time.
> I'm realy new to phptal and i can only imagine the
> template file for a page made out of a sliced image...
> Every piece of image slice using tal:attributes
> although it's a static image. IMHO if i receive a
> template from the designer i should only have to worry
> about the dynamic things in the page and not care
> about the static stuff like images, css, etc.
> 
> But I guess that's it and we'll have to deal with
> it....
> 
> Best regards,
> -=dutz=-
> 
> --- Stephan Lo <stephan.lo at uprix.de> wrote:
> 
> 
>>dutz dutz schrieb:
>>
>>Hi,
>>
>>in your presentation logic:
>>
>>$tpl->imgPath='tpl';
>>
>>
>>in your template:
>>
>><img tal:attributes="src
>>string:${imgPath}/images/pic.jpg"
>>src="images/pic.jpg" />
>>
>>yours
>>
>>stephan
>>
>>
>>
>>>Hi
>>>
>>>How do i load an image into a PHPTAL template
>>
>>using
>>
>>>rel paths so that it's visible in both template
>>
>>and
>>
>>>php script. Dir structure is something like:
>>>
>>>./index.php
>>>./tpl/page.html
>>>./tpl/images/pic.jpg
>>>
>>>if i use <img src="images/pic.jpg" /> the image is
>>>displayed ok in template but running index.php it
>>>displays only an image placehoder
>>>
>>>Thanks a lot
>>>
>>>-=dutz=-
>>>
>>>__________________________________________________
>>>Do You Yahoo!?
>>>Tired of spam?  Yahoo! Mail has the best spam
>>
>>protection around 
>>
>>>http://mail.yahoo.com 
>>>
>>>_______________________________________________
>>>PHPTAL mailing list
>>>PHPTAL at lists.motion-twin.com
>>>
>>
>>http://lists.motion-twin.com/mailman/listinfo/phptal
>>
>>>
>>>  
>>
>>
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> _______________________________________________
> PHPTAL mailing list
> PHPTAL at lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal
> 



More information about the PHPTAL mailing list