Forum OpenACS Q&A: How to use double index.adp?

Collapse
Posted by H. shefaat on
Hi, I m facing withe following problem: We want to run a multilangauge portal on openacs4.. For one it works very fine. Then we would like to put an oothe language front page. I tried to write a new index.adp (index_e.adp for English, index_i.adp for Italien ..). But the proble is this side is not shown by aolserver without error message!!!
1)Is it possible to use differnt index.adp, index_x.adp,..?
2) If not how can I have differnt front page for different language? Thanks in advance
Collapse
Posted by Ben Adida on
You probably want to look at Collaboraid's Internationalization Effort over at http:// www.collaboraid.biz/extranet/i18n/blog/.

In general, if you want to return different ADPs, make sure to set up "index.tcl" because that will be sourced first. Then, use whatever logic you need in index.tcl to return the right ADP file, which you can do using:

ad_return_template <template_name>

where <template_name> is index_e or index_s.

Collapse
Posted by H. shefaat on
Thanks fo code, Unforunatly I get this error after writing the code:
ad_return_template where is index_e
The error message is:
Too many positional parameters specified
    while executing
"ad_return_template__arg_parser"
    (procedure "ad_return_template" line 1)
    invoked from within
"ad_return_template  where  is index_e"
    ("uplevel" body line 91)
    invoked from within
"uplevel {
    	  ad_page_contract {

    OpenACS main index page.  This is the standard page that is used to allow users
    to login to the site.  Yo..."
    (procedure "code::tcl::/web/openacs-4/www/index" line 2)
    invoked from within
"code::tcl::$__adp_stub"
    invoked from within
"if { [file exists $__adp_stub.tcl] } {
 .....

Any idea what is wrong?
Thnaks
Collapse
Posted by Jeff Davis on
The correct syntax for your case is
ad_return_template index_e
You can search for procedure documentation on your server at youservername.com/api-doc/ or at http://dev.openacs.org/api-doc/ (although this is for the version running at dev.openacs.org and may be slightly out of date if you have a current cvs checkout).
Collapse
Posted by H. shefaat on
Thanks Jeff,
Aolserver use now only index_e. what I want is to use index as default. 

After clicking on a button (for instance English falg) then the server hat to go to index.e and show this page.
So I need to use double index 1) index for default 2)index_e for English.
Many Thaks
Collapse
Posted by Jeff Davis on
I suspect you will have to learn some more TCL :) If you let them set their language (with a cookie or something) like this
set lang en
ad_return_template "index_$lang"
you could get the language form the accept-language header sent by the browser. Here is a bad hacky example of that:
set lang [lindex [split [ns_set iget [ns_conn headers] accept-language] "-,;"] 0]
Collapse
Posted by H. shefaat on
Thank you Jeff,
you are right I m not a TCL/TK programmer but I think it could be possible to set up these first things.
Anyway where I have to put the code?
set lang en ad_return_template "index_$lang"
This code in index ?
set lang [lindex [split [ns_set iget [ns_conn headers] accept-language] "-,;"]
And this code alo in index?
So as you can see I dont have a lot of experience with this index, so please tel me what is exactly to do.
Thanks
Collapse
Posted by Jeff Davis on
you could put the code in index.tcl (or lots of other places).
<p>
I think you might need to spend some time reading about
programming though since I don't think given where you are
starting from you will make much progress posting.
<pre>
Some good books to read:
http://philip.greenspun.com/panda/
http://beedub.com/book/3rd/
http://philip.greenspun.com/tcl/
(Philip's are on line and Brent Welch has a couple chapters online)
</pre>