Kornel Lesiński wrote:
On 11-12-2009 at 13:31:31 Murat Corlu <muratco...@gmail.com> wrote:

We want to use a custom namespace and tags in our template files like 'fbml'. I mean, we want to render a month select box by writing a tag to our template like that:

<foo:select data="monthList" />

To use a custom namespace I added a xmlns attribute to outer tag. ( <div xmlns:foo="bar"> ) So, now, I want to render these namespace tags with custom template files. For example above, I want to generate select.html template file for all foo:select tags. I only know I can make this with filterDOM. I can walk on all elements of templates and if I find a tag of my custom namespace, I can run a custom php function and manipulate content of this tag.

But, I wonder, is there any better solution to make this? For example, can DTD files help me? Do you have any suggessions?

DTDs can't help much. Best they can do is to replace custom entity with code fragment (&fooselect;), but it's an optional (and problematic) feature in XML, and PHPTAL doesn't implement it.



I think replacement with filterDOM is a good idea. That's what this was meant for.

You don't need to transform much. You can just set tal:define and metal:use-macro attributes on this element, e.g.:

<foo:select tal:define="data monthList" metal:use-macro="foo.xhtml/select"/>

and it will be replaced with macro's code.


BTW: I've added setAttributeNS to SVN to make that possible. There might be more embarrassing omissions like that - let me know if you need any other DOM methods.


We needed these custom namespaces to use this "widgets" on our "translation texts". For example, we have a form that user enters a range data. And we want to show this form elements like that:

between <select name="foo">.....</select> and <select name="bar">......</select>

And this value changes in Turkish like that:

<select name="foo">....</select> ile <select name="bar">....</select> arasinda

As you see, we can't translate word by word because of their sorting change. Also these select boxes must be dynamic and translated. And we don't want to store big html content, tal attributes or data structure in our translate texts.

So, we are trying to create "simple", "short" and "system-data independent" custom tags that has a few attributes(parameters) to use these in our translations and templates.

I'm checking PHPTAL_DOM capabilities since several hours only. So, I couldn't analyze that what I need. But, probably I need somethings :) For example: I couldn't find that how can I change a dom element's text content yet.

Thank you Kornel!


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

Reply via email to