1

I have a problem, I have romainian character into the titles, but this code :

{exp:channel:entries channel="filme" orderby="title" sort="asc" dynamic="off" limit="1000"}
<?php
$letter = strtoupper(mb_substr('{title}', 0, 1));
if ($temp != $letter) {
    echo "<a href='$letter'>".$letter."</a>";
    $temp = $letter;
}
?>

{/exp:channel:entries}

Shows me on ș ț ă î something like these :� What should I do that the output of php to come well and make my sorting method work ? I want to build an Alphabet ..

3
  • 1
    What charset have you specified in your templates? – Jeremy Feb 13 '14 at 3:43
  • Hey @Jeremy I did specifiy in templates UTF-8 also in config.php . but no luck at all :(( – Klauss Feb 13 '14 at 8:42
  • did you try mb_substr('{title}', 0, 1, 'UTF-8') ? – Max Lazar Feb 13 '14 at 15:21
1

Try next code:

{exp:channel:entries channel="filme" orderby="title" sort="asc" dynamic="off" limit="1000"}
<?php
mb_internal_encoding ("utf-8");
$letter = mb_strtoupper((mb_substr('{title}', 0, 1)));
if (!in_array($letter, $temp)) {
    echo "<a href='$letter'>".$letter."</a>";
    $temp[] = $letter;
}
?>

{/exp:channel:entries}
5
  • Tried that one and worked out ! the only problem now is i get multiple repetition of letters like: ( . 1 3 4 A B C D E F G H I Î I Î I Î I Î I Î I Î I J K L M N O P Q R S Ş S Ş S Ş S Ş S Ş S T Ţ T U V W - where do the repeat comes from ? what is wrong in my code ? Cheers – Klauss Feb 13 '14 at 22:08
  • why do you think that this is repeated letters? I see different letters - S != Ş. Did you try to make A-Z lists ? You can try - gotolow.com/addons/low-alphabet. Also you can try to replace {title} with {url_title}. Or you can try to add letter in array and then check cond with in_array() function. In this case you will keep this lang. specific letters but remove duplications. – Max Lazar Feb 14 '14 at 1:32
  • I did try Low Alphabet, but it won't get me Romainian Foreign Characters like Ș and Ț, it will take ș as s and ț as t... – Klauss Feb 14 '14 at 8:51
  • well, in case if you want to separate it - try version with in_array. I make update for my post. – Max Lazar Feb 14 '14 at 9:08
  • Thank you For ANSWER, i have another one Here: I want when I click on a Letter to go to a link where Only That letter titles to be, What should be the filthering code ? Like an alphabet.. – Klauss Feb 14 '14 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.