Bug 31385 - Additional contents: Allow searching a CMS page by code in multilanguage env
Summary: Additional contents: Allow searching a CMS page by code in multilanguage env
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Marcel de Rooy
QA Contact: Testopia
URL:
Keywords:
Depends on: 15326
Blocks: 29190
  Show dependency treegraph
 
Reported: 2022-08-17 13:41 UTC by Marcel de Rooy
Modified: 2023-12-28 20:42 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact: Caroline Cyr La Rose
Documentation submission: https://gitlab.com/koha-community/koha-manual/-/merge_requests/679
Text to go in the release notes:
Version(s) released in:
22.11.00


Attachments
Bug 31385: Allow searching a CMS page by code (2.25 KB, patch)
2022-08-17 13:46 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 31385: Allow searching a CMS page by code (2.26 KB, patch)
2022-08-17 14:37 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 31385: (follow-up) Switch to language param (1.75 KB, patch)
2022-08-17 15:08 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 31385: (follow-up) Same change at intranet side (1.80 KB, patch)
2022-08-18 08:47 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 31385: (follow-up) Add code based URL on the staff CMS view (3.89 KB, patch)
2022-08-18 08:47 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 31385: Allow searching a CMS page by code (2.32 KB, patch)
2022-08-18 14:50 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 31385: (follow-up) Switch to language param (1.77 KB, patch)
2022-08-18 14:50 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 31385: (follow-up) Same change at intranet side (1.82 KB, patch)
2022-08-18 14:50 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 31385: (follow-up) Add code based URL on the staff CMS view (3.91 KB, patch)
2022-08-18 14:50 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2022-08-17 13:41:33 UTC
We could use the column code to switch language. Easier than keeping track of all idnew identifiers for each language.
This report adds a optional code and optional lang query parameter.
Comment 1 Marcel de Rooy 2022-08-17 13:46:00 UTC
Created attachment 139295 [details] [review]
Bug 31385: Allow searching a CMS page by code

Test plan:
Add a CMS page with two languages for it.
Look at the code column in the DB.
Try opac/opac-page.pl?code=[CODE]&lang=[LANG]. Test leaving lang
empty and passing various languages.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 2 Marcel de Rooy 2022-08-17 13:48:38 UTC
Tomas:
What do you think?
With this patch which is useful on its own already, we could also offer the URL opac-page.pl?code={CODE] instead of page_id.
The extra lang parameter is a bonus.
Comment 3 Katrin Fischer 2022-08-17 13:55:16 UTC
We already have language as a parameter for other pages, like:

OPACBASEURL/anypage?language=fr-FR

Maybe we could make it match.
Comment 4 Marcel de Rooy 2022-08-17 14:03:34 UTC
(In reply to Katrin Fischer from comment #3)
> We already have language as a parameter for other pages, like:
> 
> OPACBASEURL/anypage?language=fr-FR
> 
> Maybe we could make it match.

Good point
Comment 5 Kyle M Hall 2022-08-17 14:37:47 UTC
Created attachment 139296 [details] [review]
Bug 31385: Allow searching a CMS page by code

Test plan:
Add a CMS page with two languages for it.
Look at the code column in the DB.
Try opac/opac-page.pl?code=[CODE]&lang=[LANG]. Test leaving lang
empty and passing various languages.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 6 Marcel de Rooy 2022-08-17 14:39:12 UTC
(In reply to Marcel de Rooy from comment #4)
> (In reply to Katrin Fischer from comment #3)
> > We already have language as a parameter for other pages, like:
> > 
> > OPACBASEURL/anypage?language=fr-FR
> > 
> > Maybe we could make it match.
> 
> Good point

The problem is again with default here. If you would pass language=default it wont get accepted by getlanguage and its friends..
Comment 7 Kyle M Hall 2022-08-17 14:40:58 UTC
(In reply to Marcel de Rooy from comment #4)
> (In reply to Katrin Fischer from comment #3)
> > We already have language as a parameter for other pages, like:
> > 
> > OPACBASEURL/anypage?language=fr-FR
> > 
> > Maybe we could make it match.
> 
> Good point

What makes sense to me is to pass the id and optionally the language. Look up the news item by id. 

We now have the code based on the id. If the language of this one doesn't match the given and logged in language, use the code from this one to look of the correct language version.

This means we don't need to go mucking about in the database to find the code for the page.

Does that make sense?
Comment 8 Marcel de Rooy 2022-08-17 14:43:03 UTC
(In reply to Kyle M Hall from comment #7)
> (In reply to Marcel de Rooy from comment #4)
> > (In reply to Katrin Fischer from comment #3)
> > > We already have language as a parameter for other pages, like:
> > > 
> > > OPACBASEURL/anypage?language=fr-FR
> > > 
> > > Maybe we could make it match.
> > 
> > Good point
> 
> What makes sense to me is to pass the id and optionally the language. Look
> up the news item by id. 
> 
> We now have the code based on the id. If the language of this one doesn't
> match the given and logged in language, use the code from this one to look
> of the correct language version.
> 
> This means we don't need to go mucking about in the database to find the
> code for the page.
> 
> Does that make sense?

I will give it a try now
Comment 9 Katrin Fischer 2022-08-17 14:54:01 UTC
I don't see a need to pass default... pass a language or none. 

If you don't pass a language, this should work like the other pages:

- look at the cookie, if there is none
- look at the browser default
- if the result doesn't match existing content - use default
Comment 10 Marcel de Rooy 2022-08-17 15:02:01 UTC
Kyle suggest to pass the page_id which refers to the default record. But when you pass a language too, you could switch to the specific language.
It feels a bit odd however to do so.
I think it should be possible to pass default. You could use it as your native language in additional contents to reduce records.
Comment 11 Katrin Fischer 2022-08-17 15:04:34 UTC
I thin default will always be the native language, but it's supposed to be a fallback. I don't think that triggering it directly makes sense.
Comment 12 Marcel de Rooy 2022-08-17 15:08:10 UTC
Created attachment 139298 [details] [review]
Bug 31385: (follow-up) Switch to language param

As Katrin suggested, we should use the language URL param instead.
If you pass code, we use the language cookie as fallback.
If that does not work, we look for default.

Test plan:
Try former test plan but use code=X&language=Y.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 13 Marcel de Rooy 2022-08-17 15:11:05 UTC
(In reply to Kyle M Hall from comment #7)
> What makes sense to me is to pass the id and optionally the language. Look
> up the news item by id. 
> 
> We now have the code based on the id. If the language of this one doesn't
> match the given and logged in language, use the code from this one to look
> of the correct language version.
> 
> This means we don't need to go mucking about in the database to find the
> code for the page.

Will open another report to show this code URL on the additional contents page, and the need for looking it up will be gone.
Comment 14 Marcel de Rooy 2022-08-18 08:47:53 UTC
Created attachment 139348 [details] [review]
Bug 31385: (follow-up) Same change at intranet side

Test plan:
Try at staff side: tools/page.pl?code=CODE

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 15 Marcel de Rooy 2022-08-18 08:47:57 UTC
Created attachment 139349 [details] [review]
Bug 31385: (follow-up) Add code based URL on the staff CMS view

Test plan:
Create a page with contents in two languages.
Verify that the Default URL shows the default content and the
Current language URL shows content based on active language.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 16 Marcel de Rooy 2022-08-18 08:48:35 UTC
(In reply to Marcel de Rooy from comment #13)
> (In reply to Kyle M Hall from comment #7)
> > What makes sense to me is to pass the id and optionally the language. Look
> > up the news item by id. 
> > 
> > We now have the code based on the id. If the language of this one doesn't
> > match the given and logged in language, use the code from this one to look
> > of the correct language version.
> > 
> > This means we don't need to go mucking about in the database to find the
> > code for the page.
> 
> Will open another report to show this code URL on the additional contents
> page, and the need for looking it up will be gone.

Decided to put it here also.
Comment 17 Nick Clemens (kidclamp) 2022-08-18 14:50:03 UTC
Created attachment 139390 [details] [review]
Bug 31385: Allow searching a CMS page by code

Test plan:
Add a CMS page with two languages for it.
Look at the code column in the DB.
Try opac/opac-page.pl?code=[CODE]&lang=[LANG]. Test leaving lang
empty and passing various languages.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 18 Nick Clemens (kidclamp) 2022-08-18 14:50:07 UTC
Created attachment 139391 [details] [review]
Bug 31385: (follow-up) Switch to language param

As Katrin suggested, we should use the language URL param instead.
If you pass code, we use the language cookie as fallback.
If that does not work, we look for default.

Test plan:
Try former test plan but use code=X&language=Y.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 19 Nick Clemens (kidclamp) 2022-08-18 14:50:10 UTC
Created attachment 139392 [details] [review]
Bug 31385: (follow-up) Same change at intranet side

Test plan:
Try at staff side: tools/page.pl?code=CODE

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 20 Nick Clemens (kidclamp) 2022-08-18 14:50:14 UTC
Created attachment 139393 [details] [review]
Bug 31385: (follow-up) Add code based URL on the staff CMS view

Test plan:
Create a page with contents in two languages.
Verify that the Default URL shows the default content and the
Current language URL shows content based on active language.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 21 Marcel de Rooy 2022-08-19 06:05:05 UTC
(In reply to Nick Clemens from comment #20)
> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Thx Nick
Comment 22 Tomás Cohen Arazi 2022-08-19 19:05:21 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 23 Lucas Gass 2022-10-14 19:25:44 UTC
Not needed in 22.05.x