Multi Language for Blog?
Hey, quick question... we have applied the multi-language region for each content page - works well and easy enough for client to edit.
But how do we set this up for Blog?? Or Events, Galleries etc. Standard content is fine but when listing items from custom arrays, where/how do we add the lang variable?
For standard content I used the code: <?php perch_content('My Content Area Name - '.$lang); ?>
Thanks.
How about using sections or categories?
Hmmm.... I don't really want to duplicate each Blog entry 4 times... particularly as they are already populated and have a heap of images in each.
I have four icons to switch languages, which is working great for generic content.
What I would really like is to have just the one text field duplicated four times in each Blog entry for the different languages and perhaps use a perch if to show/hide maybe??
Yes, you could do that. Add the extra fields to your
post.html
template.So would need to check for the variable if set and default to English... will see how we go!
Yes, that's right.
Just on this... trying to use perch:if to check the variable value of "lang" in the URL but not having much luck?? Also trying to get it working for the icon nav...
For example, URL would be /about.php?lang=de
Template for icons to change language... (links are working fine, just trying to get on states working).
Am I going about this the wrong way?
We did have a JS function working well for on states but if no lang was defined in URL we got stuck, so thought it might be easier to bring into Perch.
Are you passing the
lang
variable into the template? If not:Yeah, using content custom... but not getting anything out??
If I get vars on about.php?lang=de I see the below, so it should work yeah?
There is no template error location and the template is as original post.
What does
<perch:showall />
output for your template?Nothing.... ?
Which version of Perch are you using? It should be 2.8.8.
Yep.
Perch: 2.8.8 PHP: 5.4.37 MySQL: mysqlnd 5.0.10 - 20111026 Server OS: Linux, cgi-fcgi Installed apps: content (2.8.8), assets (2.8.8), categories (2.8.8), perch_forms (1.8.3), perch_blog (4.6)
Ok,
<perch:showall />
should output in your template. If not, you have bigger issues.OK... something is specifically wrong with this template or page...
If I add <perch:showall /> to other templates it works fine.
So...
Does it matter what you call the custom content region?
Should you see this region come up in Perch Admin? Because I can't.
I'm getting the same issues on two different servers - one runs over 20 of our Perch sites without issue, so assume it can't be a php setting.
The template should just be in the "../templates/content/" folder yeah?
Oh, just realised... this is in the header and loading from includes folder. Do I need to set any paths anywhere??
If you turn on debug, what does it output?
Shows one alert:
Full Debug Message:
For some reason this is repeated twice...
So that's telling you that the page
/about.php
does not have a region calledLanguages
.Would you dispute that?
Wow yeah... somehow I managed to clobber this region: <?php perch_content('Languages');?>
This is what happens when you code at 1am.......... So... yeah, sorry to waste your time, all good now thanks.
OK, well that made it load, but obviously duplicated it, so now I removed it from page below and it works.... anyhow??
So is that the normal way to use perch_custom_content?? To add the target region then delete??