Le 05/07/2010 00:31, Tamer Higazi a écrit :
> Thank you Christoph.
>
> Last question about this subject:
>
> let us say....
>
> JS content
>
> <head>
> <script language="text/javascript>
> function MyBlock()
> {
> ....
>
> ....
> }
> </script>
> <head>
>
>
> ....
>
> how would you make the function with ZTPL disappear?!You can write a content provider (see zope.contentprovider), and since the contentprovider is a Python class, you can make it write something or nothing if you need. If you need to include several pieces of js, consider writing a viewlet for each one, and create a viewlet manager for all the js viewlets. Viewlets and content-providers are almost the same thing (they are just multi-adapters). Another option is to use some tools like zc.resourcelibrary or some other z3c library for that usage. > > and the other question: > Is there a way to make sub templating with ZTPL?! > > let us say one for the base layout > the next one for the navigation left (menu) > and the 3rd one for the content.... You do that with METAL macros. You first write a master template in which you define some macros (metal:define-macro="...") and some slots (metal:define-slot="..."). for example on macro for the content, one for the left column, one for the head includes (js, css). Then for a specific view, you'll use a child template, in which you specify a macro you want to use (use-macro="..."), and you provide some content for the slots in the macro (fill-slot="..."). You should read the docs of METAL macros. A convenient way to register and use macro is with z3c.macro. It's much simpler than registering a view to access macros. If you're not comfortable with macros, you can do eveything with viewlets and viewlet managers. Or even use some other advanced concepts such as z3c.pagelet. > > > Tamer > > > > Am 01.07.2010 12:25, schrieb Christophe Combelles: >> You have several ways of doing it: >> either use the omit-tag Tal attribute, or use tal-replace if you don't >> want the tag, or use an tag in the tal namespace like<tal:block >> content=... >> or use a macro to include something from a child template, or event >> create a content-provider >> >> Christophe >> >> ----- Reply message ----- >> De : "Tamer Higazi"<[email protected]> >> Date : mer., juin 30, 2010 23:48 >> Objet : [BlueBream] zope templating >> Pour :<[email protected]> >> >> Hi people! >> Question, is there anyway to use the ZTPL to create content on the fly >> whereever in the document? Or will I ALWAYS have to set the tal >> attribute in a tag. >> >> for me specially usefull to decide generating JS code and take out >> certain segments of a document if I want to. >> _______________________________________________ bluebream mailing list [email protected] https://mail.zope.org/mailman/listinfo/bluebream
