Forums / Developer / How to link to a new template(not override ones)

How to link to a new template(not override ones)

Author Message

Toms King

Wednesday 16 August 2006 11:13:10 pm

Hi, all,

I create a new template, maybe named contact.tpl, then where should I put this template

and what link can I put to link to this template?

Another question hah, I create a new table in the database, then how can I retrieve the data

in this table, or perform the search function to this table? For example, the table name is

company, the names of attributes in this table are compangy_id, company_name.

Thank you very much for your attention.

Best regards,

Toms

Claudia Kosny

Sunday 20 August 2006 2:36:21 pm

Hello Toms King,

If you want to include this new template in another template, you can use the 'include' command roughly like this:
{include uri='design:contact.tpl' something='Hello world'}

The template contact.tpl must be found in one of the design directories. Mor information here:
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_functions/miscellaneous/include

If you want to override another contact.tpl (e.g from the base design' with yours) the easiest way is to recreate the location where the original tpl file is located in your design directory. E. g. if the original template file is located in design\base\override\templates\collectedinfo\contact.tpl
your override template must be
\design\your_design_folder\override\templates\collectedinfo\contact.tpl

If you don't want to or can't recreate the folder structure and use the same filename as the original template, you have to create an override in the override.ini. You can find lots of information about that here:
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_override_conditions

Regarding your question about the database I can't help you right now - I have never tried something like this although it certainly could be useful. If you find useful information on how to so it, I would appreciate a post.

By the way: It would have been better to post two different questions in two different posts, as some people will not look into post if the heading is not interesting. This way you might miss out on the database experts here.

Greetings from Luxembourg

Claudia

Toms King

Sunday 20 August 2006 6:31:03 pm

Sorry yah, I think u mistake what I mean.

I want to create a link in a existing template to another template which is created by myself.

but not sure what url should I put there

I tried design:contact/contact.tpl

but cannot find the file (the file is contact.tpl put in design/contact folder)

Claudia Kosny

Monday 21 August 2006 12:27:06 am

Ah, now I understand.
Unfortunately I do not know of way to do that directly. The way I would do it (although there is hopefully a better one) is to create a dummy node somewhere in the tree, then override the default template for this node with your contact.tpl and then link to this dummy node. This way your template will be displayed.
I know this solution is far from perfect but if you have only one or two templates you want to display like this it should work fine. If you find a better way please post it here, it might be useful.

Greetings from Luxembourg

Claudia

Toms King

Monday 21 August 2006 12:42:07 am

Thanks very much, Claudia.

How great it is that I just got the idea the same as u suggest me, haha ^__^

Claudia Kosny

Tuesday 22 August 2006 1:19:25 am

Hi Toms,

regarding the problem with fetching data from a new table in your database:
Have a look at this:
http://ez.no/products/ez_publish/documentation/development/extensions/module/module_tutorial_part_1

It is fairly old and not complete but might give you some ideas on how to start.

Claudia

Toms King

Thursday 24 August 2006 6:48:49 pm

Thanks, Claudia

and for create own template, I think I got a new idea

create the new template for example test.tpl under the folder

design/my_site/templates/node/view

and the access url is http://localhost/my_site/content/view/test

but a new question comes, how can I pass value to this template

I already know we can pass node object to the new template, use the like that

http://localhost/my_site/content/view/test/60 here 60 is treated as the node_id

but how can I pass other datatypes of value to this template, such as array, string

do I need to define somewhere in the kernel?