Hi Mark,
Any progress adding category custom fields? I think this existing plugin with that one last feature added will finally be the last piece in the multi-language puzzle.
I’m starting a new project soon and I’ll need to decide which approach to use…
No rush though… 😊
Thanks a million!
I’ve basically got Simple Translator working, great stuff. However, I need to add an id attribute to each list item (for styling purposes).
Example:
<ul class="simple-translator">
<li id="English" class="selected first"><a href="http://" title="English">English</a></li>
<li id="German"><a href="http://" title="German">German</a></li>
<li id="Dutch"><a href="http://" title="Dutch">Dutch</a></li>
<li id="French"><a href="http://" title="French">French</a></li>
<li id="Italian" class="last"><a href="http://" title="Italian">Italian</a></li>
</ul>
I’d be happy with a class attribute instead, of course.
How can I adapt the extension to add these attributes automatically? I’ve had a look in the extension file itself but don’t see any reference to an unordered list at all.
Thanks!
Hi lithiumdave,
You could always create the list in you templates like so:
<ul class="simple-translator">
<li id="English" {if simple_language == "English"}class="selected first"{/if}>
<a href="/lang/default/" title="English">English</a>
</li>
<li id="French" {if simple_language == "French"}class="selected first"{/if}>
<a href="/lang/_fr/" title="French">French</a>
</li>
etc...
</ul>
Now that works really well! Almost…
The only bit I’m struggling with now is the path. For example, a href=”/lang/_de/” finds the root of the site, so I get a 404. The path needs to basically append /lang/_de/ (I think!) to the end of whatever the URL happens to be, in the way that the extension does.
Is there a way of achieving this with a hard-coded path, as in your example?
Many thanks for your help so far 😊
I’ve done it like this anyway:
<?php
$domain = $_SERVER['HTTP_HOST'];
$url2 = "http://" . $domain . $_SERVER['REQUEST_URI'];
?>
<ul class="simple-translator">
<li id="English" {if simple_language == "English"}class="selected first"{/if}>
<a href="http://<?php" title="English">English</a>
</li>
<li id="German" {if simple_language == "German"}class="selected"{/if}>
<a href="http://<?php" title="German">German</a>
</li>
<li id="Dutch" {if simple_language == "Dutch"}class="selected"{/if}>
<a href="http://<?php" title="Dutch">Dutch</a>
</li>
<li id="French" {if simple_language == "French"}class="selected"{/if}>
<a href="http://<?php" title="French">French</a>
</li>
<li id="Italian" {if simple_language == "Italian"}class="selected"{/if}>
<a href="http://<?php" title="Italian">Italian</a>
</li>
</ul>
It seems to be working ok so far at least. Be interested to learn if there’s a non-PHP way to tackle it.
Cheers.
As I thought, I’m here again…
The client has now decided that they want category names to also language switch too, even though they insisted they wouldn’t need that when I began.
I’m struggling with implementing category language switching and would appreciate some help, rather urgently in fact!
I have the following code in my templates to output the list of categories, as well as also display the list of entries within each category. Further, there are conditionals in there too to conditionally display entries only if you’re actually viewing that category.
I’ll simplify it next, but just wanted to show what I’ve actually got in there first:
<ul class="sidenav">
{exp:weblog:categories weblog="products" style="linear"}
<li {if "{segment_2}" == "C{category_id}" OR "{segment_3}" == "{category_id}"}class="subcurrent"{/if}><a href="http://{path=products}">{category_name}</a>
{if "{segment_2}" == "C{category_id}" OR "{segment_3}" == "{embed:cat}"}
<ul>
{exp:weblog:entries weblog="products" category="{category_id}" dynamic="off"}
{if "{embed:current}" != "{url_title}"}<li><a href="http://{homepage}products/{url_title}/{category_id}/">{title}</a></li>{/if}
{if "{embed:current}" == "{url_title}"}<li><span>{title}</span>{/if}
{/exp:weblog:entries}
</ul>
{/if}
</li>
{/exp:weblog:categories}
</ul>
I suppose broken down to brass tacks it’s simply this:
{exp:weblog:categories weblog="products" style="linear"}
<li><a href="http://{path=products}">{category_name}</a>
<ul>
{exp:weblog:entries weblog="products" category="{category_id}" dynamic="off"}
<li><a href="http://{homepage}products/{url_title}">{title}</a></li>
{/exp:weblog:entries}
</ul>
</li>
{/exp:weblog:categories}
Now, following Mark’s instructions I’ve done the following to the above:
{exp:weblog:categories weblog="products" style="linear"
category_group="{exp:translator:simple category_group="2"}"}
as the category group is 2. The category name is ‘Products’.
I’ve now created a new category group called ‘Products_fr’ (which has a group id of 3). However, when I switch languages (to French, using a _fr suffix) no categories whatsoever are output to the page.
I think I might be able to see why, but I just cannot figure out the solution.
Any help very very much appreciated : )
Dave
lithiumdave – is there any way you can place an {exp:weblog:entries /} tag onto the page and make sure that normal custom fields are switching? Thanks. Also, can you turn on template debugging and try to find the call to the weblog:categories method? Are there any attributes associated with it? If possible can you PM me a txt file of your template debugger?
Thanks for the quick reply Mark, really appreciate it.
I can confirm that normal custom fields are switching no problem, I have it set up here:
http://hotbox.bluestormtests.co.uk and http://hotbox.bluestormtests.co.uk/products/hotbox-heater/4/ are perfect working examples.
You can see the category switching not working on this page:
http://hotbox.bluestormtests.co.uk/products/hotbox-heater/4/ (click the 2nd from right flag, French, at the top of the page - I only have a French category group set up so far, Products_fr)
I’ll PM you the debugging output from that template, and also login details to the CP.
Thank you SO MUCH for your help Mark, you’re a legend.
It’s odd - I’ve put category_group=”2” and categories get output just fine. Any other number - no joy. I’ve tried category_group=”3” but…
Ah, wait… I need to assign my new language-based category groups to the Products weblog in Admin too don’t I? Doh!
Right… once I do that then the correct categories do display!
However, the category links are now incorrect, so when I click any categories they’re going to a blank page.
But then I need to go into each entry again and assign each product to each of the new language-based categories don’t I??
If all my presumption are correct then (a) I am indeed an idiot and (b) my issue is solved and (c) you’re a very very patient man, thank you for your time 😊
Dave
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.