multilingual static page feature request

Creating and modifying plugins.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Uhm, no, this code piece just makes sure to append the already possibly existing query string to a URL formed "pretty URL" querystring, like "index.php?/pages&mycustom_argument1=skljd" etc. This is important to add all existing URL variables to the next permalink.

We cannot apply your fix because it would then loose all possible user-added input strings to a query.

Maybe if you can more exactly explain what that fix does (how the URL looks before, and what it should look like using your patch) I can think about how to solve this without affecting other parts?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
ormus7577
Regular
Posts: 122
Joined: Sat Nov 04, 2006 12:11 pm
Location: Ulm, Germany

Post by ormus7577 »

But it will still append all possible query strings/paths to the url, unless there are no query strings/paths to append. Only in that case will it not print a '?' between index file and query data.

The problem is, the current code returns index.php? as the current location. The language selector uses this a parameter which is checked by the static page plugin. And 'index.php' != 'index.php?', so it fails to find other start pages...
my installations:
family blog: http://familie.lobenstein.info/
personal blog: http://www.ormus.info/
OrmusTool Homepage: http://tool.ormus.info/
Online Adventskalender: http://www.ormus.info/pages/advent.html
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

The better fix would be to check in the plugin if preg_match('@' . $serendipity['indexFile'] . '\??$@', $yoururl) instead.

This has to advantages:

1. People don't need to upgrade to serendipity 1.2 to benefit from a working fix.

2. Existing plugins that REQUIRE "index.php?" instead of "index.php" will not be broken.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
ormus7577
Regular
Posts: 122
Joined: Sat Nov 04, 2006 12:11 pm
Location: Ulm, Germany

Post by ormus7577 »

Alright, I'll check this out and will have a look at the static pages plugin... (regexp and me, we ain't big friends, you know)

I'm probably still missing the bigger picture of s9y's code sometimes, but I'll continue chasing bugs, whenever I find one...
my installations:
family blog: http://familie.lobenstein.info/
personal blog: http://www.ormus.info/
OrmusTool Homepage: http://tool.ormus.info/
Online Adventskalender: http://www.ormus.info/pages/advent.html
ormus7577
Regular
Posts: 122
Joined: Sat Nov 04, 2006 12:11 pm
Location: Ulm, Germany

Post by ormus7577 »

Alright, it's working as can be seen on http://tool.ormus.info/

Code: Select all

//if ((empty($args) || trim($args) == $serendipity['indexFile']) && empty($serendipity['GET']['subpage'])) {

if ((empty($args) || preg_match('@' . $serendipity['indexFile'] . '\??$@', trim($args))) && empty($serendipity['GET']['subpage'])) {
(serendipity_event_staticpage.php, old code commented)
my installations:
family blog: http://familie.lobenstein.info/
personal blog: http://www.ormus.info/
OrmusTool Homepage: http://tool.ormus.info/
Online Adventskalender: http://www.ormus.info/pages/advent.html
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Thanks a lot, I just committed your fix!

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
ormus7577
Regular
Posts: 122
Joined: Sat Nov 04, 2006 12:11 pm
Location: Ulm, Germany

Post by ormus7577 »

On a related topic:

I'm currently changing the static page plugin to improve the multi-language capabilities. Next one is: static pages should be displayed depending on the current $serendipity['lang'] setting.

Example: You just link to pages/about.html. The code checks the language setting (be it a general setting or set by the language picker) and serves you the best possible language version. The same way it works with the startpage...

Any pointers where to start looking? I've checked the database, duplicate permalinks for static pages are allowed, so it should be sufficient to create static pages with identical permalinks. And check for the language when selecting the static page from the db. I'm just not sure where to check it, which function/hook is called by s9y when a permalink is requested?
my installations:
family blog: http://familie.lobenstein.info/
personal blog: http://www.ormus.info/
OrmusTool Homepage: http://tool.ormus.info/
Online Adventskalender: http://www.ormus.info/pages/advent.html
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Maybe you can have a look at the serendipity_event_multilingual event plugin. This one does what you want to do to static pages to entries, so you might be able to transfer sets of code?

Beware - this multilanguage stuff gets complicated. :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
ormus7577
Regular
Posts: 122
Joined: Sat Nov 04, 2006 12:11 pm
Location: Ulm, Germany

Post by ormus7577 »

Sadly the multilingual event plugin is not of much help, as it handles the language settings via entryproperties table, while the static page plugin stores the language setting in it's staticpage table.

However: I've tried some magic and managed to enable multilanguage for static pages by just adjusting some sql statements in the plugin. It seems to work, but it looks to trivial to trust it :shock: . Need to investigate that a little more tonight.

Only works for [subpage]=pagetitle links though, not for permalinks (it's depending on the GET parameter, which is absent when using permalinks). One has to use identic pagetitles for language versions, making the dropdown list in the backend somewhat useless...

FYI, here's what I've changed:

Code: Select all

file: serendipity_event_staticpage.php
function: getPageID() and selected() (not sure if getPageID needs to be adjusted)

Select id from bla where pagetitle=subpage or permalink=subpage (pseudocode ;) )

changed to:
select id from bla where (pagetitle=subpage or permalink=subpage) and (language = $serendipity['lang'] or language='all' or language='')
As you can see, still some question marks around, but it IS working. Stay tuned (or comment).
my installations:
family blog: http://familie.lobenstein.info/
personal blog: http://www.ormus.info/
OrmusTool Homepage: http://tool.ormus.info/
Online Adventskalender: http://www.ormus.info/pages/advent.html
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Actually, that code modification does look decent to me. I think that should work :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
ormus7577
Regular
Posts: 122
Joined: Sat Nov 04, 2006 12:11 pm
Location: Ulm, Germany

Post by ormus7577 »

Seriously, I have no idea why it's working with permalinks as well ;)

The sidebar plugin is updated as well... So it looks pretty good. Still can't believe, that it is THAT easy. We should update the backend though, because the dropdown list is rather useless. And we should mention in the help comments, that identical permalinks/pagetitles have to be used.
my installations:
family blog: http://familie.lobenstein.info/
personal blog: http://www.ormus.info/
OrmusTool Homepage: http://tool.ormus.info/
Online Adventskalender: http://www.ormus.info/pages/advent.html
mad-manne
Regular
Posts: 42
Joined: Wed Jan 23, 2008 4:56 pm
Location: Marl, Germany
Contact:

Post by mad-manne »

ormus7577 wrote:Don't you just love 'ancient' threads being dragged into daylight again? :D
Sorry I couldn't resist, but this is apparently *the* thread that covers my problem ... :oops:
And we should mention in the help comments, that identical permalinks/pagetitles have to be used.
Well ... from reading this thread I still don't quite understand the way the whole system is supposed to work :shock:
Is there any place, that the intended behaviour of the "multi-lingual-feature" of the static-pages-plugin is described in depth ?

From my current tests it looks like this:
  • In Administration/Configuration/General Settings I have "Language" set to English and "Use visitor's browser language as default" set to Yes
  • I have 2 static pages setup ...
    • "Willkommen"(headline)
      /infos/welcome.html(permalink)
      German(language)
    • "Welcome"(headline)
      /infos/welcome.html(permalink)
      English(language)
  • In both pages I have set "Make this page the frontpage of Serendipity" to Yes
Now if I visit the page with browser set to german as the preferred language, the startpage shows as desired. Same "appears" to be true, if I visit with a browser set to english, because I can see the english content of the static-page that has been set to english ... but if I click on the link for that article in the static-page sidebar-plugin ... the german page appears :?
I have made 2 other static pages(not set to be the frontpage), but with the same permalink and again in german and english, but here the behaviour is even more confusing. While the first-mentioned pages appear in the desired language within the list of static pages in the sidebar .. it is vice-versa with the second 2 pages. In the "german" browser I see the english headline in the sidebar, where the "english" browser shows the german headline of that page. A click on either link brings me to the german content of that static page.

Can anyone report any similar behaviour?

I'd be willing to try and find a solution myself, but before I start, I would like to know if anyone else is currently working on this issue?

Should I decide to start, you will have to admit some time, because I am still pretty new to s9y and will have to spend some time, to get used to the way things work here :-P

And to make a long story even longer, I would also like to know if anyone would also like to see a "super-default-language"-feature for the static pages? I think of a special "default-language" for static pages that should define which "language-set" of static pages would appear to a visitor that comes along with an "uncovered" language.
In my special case I want to offer static pages in german and english, where english should be the "super-default". Like this a visitor with a "german" browser would only see the german pages, an "english visitor" sees the english pages and all other users would also see the english ones.
Currently any visitor with a language, that doesn't hava any corresponding static-pages doesn't see any of them at all.

I'm looking forward to your feedback ...
Manfred.
Try not. Do or do not. There is no try. (YODA)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Sadly I can only reply to your question, that I'm not currently working on this issue. But I'd be interested in your findings, if you can spare the time :)

I also think it would be nice to set a "default" language for a staticpage, in case no staticpage exists for a wanted language!

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
mad-manne
Regular
Posts: 42
Joined: Wed Jan 23, 2008 4:56 pm
Location: Marl, Germany
Contact:

Post by mad-manne »

garvinhicking wrote:I also think it would be nice to set a "default" language for a staticpage, in case no staticpage exists for a wanted language!
Hi Garvin,
to start getting into the s9y-code and because I need that "default-language"-feature, I would try and start off with that.

I have looked through the code and found 2 interesting variables
  • $serendipity['lang']
  • $serendipity['autolang']
I would guess, that when used in a plugin, that $serendipity['lang'] will actually contain the value of the currently used language, no matter if it comes from the main blog-configuration, automatic detection or from the "Choose Language"-plugin ??

Can you(or anyone else) confirm, that $serendipity['lang'] is *the* variable to look at, when I'm trying to find out which language is active for the current user ?

Thanks,
Manfred.
Try not. Do or do not. There is no try. (YODA)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
I have looked through the code and found 2 interesting variables
  • $serendipity['lang']
  • $serendipity['autolang']
I would guess, that when used in a plugin, that $serendipity['lang'] will actually contain the value of the currently used language, no matter if it comes from the main blog-configuration, automatic detection or from the "Choose Language"-plugin ??
That's true! $serendipity['lang'] is the variable all s9y functions rely on.

The multilingual plugin itself uses other variables too, though, to indicate content language. $serendipity['lang'] is basically only used to indicate which lang/serendipity_lang_XX file with constants was loaded.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply