On Thu, 2006-09-14 at 15:26 +0300, Sjur Moshagen wrote:
> Hello,
>
> I'm trying to make my first dispatcher contract. It turned out to be
> more problematic than I first thought, problems below the pseudocode.
>
> Here's what I want to do: I want to create a language selection list
> for a multilingual site. The language selection list should be
> dynamically generated for each document, since it isn't known which
> document have more than one language, and which languages are
> available for each document. The pseudocode goes like this:
>
> 1- get the request
> 2- get a list of all documents that matches the request, disregarding
> i18n infixes in the
> filenames (that is, a request for X.html should match all of:
> X.YY.xml
> X.ZZ.xml
> X.xml
> where YY, ZZ and <nothing> corresponds to available locales or
> the fallback file
> 3- examine the X.xml (fallback file) for an @xml:lang or @lang to
> determine the
> language of the document; if not found, use the site default (if
> available)
> 4- based on 2 and 3, create a list of all languages available
> 5- examine the document actually being returned by the request for
> @xml:lang or @lang,
> to be able to detect the currently viewed language (it could be
> different from
> the fallback document, since other i18n components can have
> picked a better
> choice based on browser settings)
> 6- return a list of available language variants, tagging the
> presently displayed
> language, and with each of the other languages as a link to that
> document (using,
> e.g. ?locale=YY or some other means to override browser settings)
>
> The list should be formatted with CSS to whatever is wanted. My
> present goal is to have a simple horisontal list across the page,
> between the menu on the left and the PDF icon on the right, just
> above the document title.
>
> Problem #1:
>
> I can't get the contract to do anything!
>
> I have in my {$project}/resources/themes/pelt.fv the following snippet:
>
> <forrest:hook class="languages">TEST
> <forrest:contract name="language-variants" />
> </forrest:hook>
>
> but it only returns an empty
>
> <div class="languages"/>
Meaning the hook get transformed the contract not. BTW the TEST is not
allowed in this position.
>
> for the hook. The first version of the contract, located in
> {$project}/resources/themes/common/html/language-variants.ft,
> contains the following:
Please try requesting:
http://localhost:8888/resolve.contract.html.language-variants or AFAIR
for your case
http://localhost:8889/resolve.contract.html.language-variants Does the
contract show up?
If not, does {lm:themer.project.dir} point to the dir? What does
http://localhost:8888/ls.contracts.project.html return? Is the contract
listed?
>
> <?xml version="1.0" encoding="UTF-8"?>
> <forrest:contract
> xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
> xmlns:forrest="http://apache.org/forrest/templates/1.0"
> name="language-variants">
>
> <description>
> <p>
> <strong>language-variants</strong> will output a list of
> available language for a given
> input document. The presently displayed language will be marked.
> Styling
> is done using CSS.
> </p>
> </description>
> <usage><![CDATA[<forrest:contract name="language-variants"
> dataURI="cocoon://#{$getRequest}.languages.xml"/>]]></usage>
> <forrest:template xmlns:forrest="http://apache.org/forrest/
> templates/1.0"
> name="language-variants" inputFormat="xsl">
> <xsl:stylesheet version="1.1"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:template match="/">
> debug string -
> <forrest:content>
> <forrest:part>
> <xsl:comment>+ |start language list +</xsl:comment>
> <div class="language-variants">
> SME
> </div>
> <xsl:comment>+ |end language list +</xsl:comment>
> </forrest:part>
> </forrest:content>
> </xsl:template>
> </xsl:stylesheet>
> </forrest:template>
> </forrest:contract>
>
> I would hve expected it to output "SME", but nothing shows up.
The contract looks alright. The only thing that you define in the usage
<forrest:contract name="language-variants"
dataURI="cocoon://#{$getRequest}.languages.xml"/> and in your structurer
<forrest:contract name="language-variants" />. That should not matter
ATM for the testing but later on you may want to change this in the
structurer.
> I have tried to read and follow the instructions at:
>
> http://forrest.apache.org/docs_0_80/howto/howto-structurer-
> contracts.html
>
> and related pages linked to at the bottom.
>
> Any guidance would be greatly appreciated!
Please report back when you tested the above links and tell us what the
outcome is.
salu2
>
> Best regards,
> Sjur
>
--
thorsten
"Together we stand, divided we fall!"
Hey you (Pink Floyd)