Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#691 2024-07-29 21:32:01

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 638
Website

Re: gbp_permanent_links

jakob wrote #337486:

I think I once tried that one out before and it worked. Just need to find it… I’ll post back if I do.

EDIT: Hah, I did do it before … and it was for you! I guess we both forgot about it.

Wow, I have completely forgot about it, I have just took a look at the emails between us from 3 years ago and didn’t remembered any of that at all, so sorry about it 🙏😅🤦♂️

Thank you so much, I gave it a try and it seems to work really good 👍👏

Offline

#692 2024-07-30 08:54:45

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,233
Website GitHub

Re: gbp_permanent_links

Cool! Pleased it helps. Not sure whether to publish it properly as it only handles the url routing and permlink generation side of things. It’s just behind the scenes tools: you have to construct your site to respond properly to the current language. You also have the particularity on your site that your “home” language has no language prefix.

It is mostly suited to sites where one article has multiple languages stored within the same article, i.e. using custom fields or some other method where a single article acts as the base url for different language content pulled in from elsewhere – for example page-less sections as parallel language articles linked by a parent custom field as Oleg has described here.

I’d be interested to hear how you have structured your multi-lingual site and/or content.

Most of the small-ish multi-language sites I have made have parallel url structures in their respective languages that reference the other language via a custom field (in articles, sections, etc.), so I’ve rarely used the setup you have here.


TXP Builders – finely-crafted code, design and txp

Online

#693 2024-08-20 16:43:20

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 638
Website

Re: gbp_permanent_links

Thank you, I do use it with custom fields.
I created a form and named it “article_vars” and in it I’m doing so:

<txp:variable name="article_title"><txp:title /></txp:variable>
<txp:variable name="article_body"><txp:body /></txp:variable>

<txp:if_variable name="lang" value="en">
    <txp:variable name="article_title"><txp:custom_field name="title_en" /></txp:variable>
    <txp:variable name="article_body"><txp:custom_field name="body_en" /></txp:variable>
</txp:if_variable>

In my “header” form I’m doing so:

<txp:variable name="lang" value="he" />
<txp:variable name="langName" value="Hebrew" />

<txp:if_plugin name="jcr_langprefix_url">
	<txp:variable name="lang_prefix"><txp:jcr_page_langprefix /></txp:variable>

	<txp:if_variable name="lang_prefix" value="en">
		<txp:variable name="lang" value="en" />
		<txp:variable name="langName" value="English" />
	</txp:if_variable>
</txp:if_plugin>

Then I’m ouptput the “article_vars” form where needed, for example:

<html>
<body>
    <txp:output_form form="header" />

    <txp:article> (or article_custom)

        <txp:output_form form="article_vars" />

        <h1><txp:variable name="article_title" /></h1>
        <div><txp:variable name="article_body" /></div>

    </txp:article>

    <txp:output_form form="footer" />
</body>
</html>

Offline

#694 2024-08-20 21:05:29

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,233
Website GitHub

Re: gbp_permanent_links

Thanks for the explanation. I’ve done something similar for a recent site. I have a page_vars form at the very top of the page, a bit like you have for articles, that sets various variables including the page’s lang variable.

Then, in my page template I use different forms, different custom_fields, and different variables, even different logo filenames that end in _en or _de. You can then build your form attributes in txp:article, txp:output_form, txp:section_list etc. using the page’s language variable, e.g. form='myform_<txp_variable name="lang" />'.
The advantage is you end up with fewer if … else constructions in your template.

For custom strings I used smd_babel and made a tiny plugin that is essentially the same “txp:text” but with a lang attribute. Bloke may make that part of the plugin in a forthcoming version.


TXP Builders – finely-crafted code, design and txp

Online

#695 2024-08-20 22:11:27

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 638
Website

Re: gbp_permanent_links

jakob wrote #337687:

The advantage is you end up with fewer if … else constructions in your template.

Thanks for the tips 👍

Offline

Board footer

Powered by FluxBB