Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - host

Pages: 1 2 [3]
31
Hi V@no, hello all,

I'm a 'new' user of 4images and found this fantastic MOD.
A long time ago the question about the sorting problem was discussed here:

nice thing - there's a lot to change, to have this feature working flawless :)

But there's one little problem I could not solve on my own:


If you have a category and you set sorting by image name - it will absolutely mess up the sorting in there, if you rename some of the pictures to support more languages...
See here: http://photo.overlord.cz/categories.php?cat_id=38

How would it be possible to sort the images by the shown image name, not by the "whole image name" containing [czech] etc.?

For me the general problem of the sorting order (not only with this MOD) was relevant, so I tried to fix it.

I made a small addition in the function.php:

Original
Code: [Select]
function multilang($text, $show_first = 0, $remove = 0){
  global $config;
  preg_match("#\[".$config['language_dir']."\](.*)(\[\/?".$config['language_list']."\]|$)#iDUs", $text, $match);
  if (!empty($match[1])) {
    return $match[1];
  }
  preg_match("#^(.*)\[".$config['language_list']."\]#iDUs", $text, $match);
  if (!empty($match[1])) {
    return $match[1];
  }
  preg_match("#\[".$config['language_dir_default']."\](.*)(\[\/?".$config['language_list']."\]|$)#iDUs", $text, $match);
  if (!empty($match[1])) {
    return $match[1];
  }
  if ($show_first) {
    preg_match("#\[".$config['language_list']."\](.*)(\[\/?".$config['language_list']."\]|$)#iDUs", $text, $match);
    if (!empty($match[2])) {
      return $match[2];
    }
  }
  if ($remove) {
    return preg_replace("#\[".$config['language_list']."\](.*)#iDs", "", $text);
  }
  return $text;
}

Changed:
Code: [Select]
function multilang($text, $show_first = 0, $remove = 0){
  global $config;
  preg_match("#\[".$config['language_dir']."\](.*)(\[\/?".$config['language_list']."\]|$)#iDUs", $text, $match);
  if (!empty($match[1])) {
    return $match[1];
  }


  preg_match("#\[default\](.*)(\[\/?".$config['language_list']."\]|$)#iDUs", $text, $match);
  if (!empty($match[1])) {
    return $match[1];
  }


  preg_match("#^(.*)\[".$config['language_list']."\]#iDUs", $text, $match);
  if (!empty($match[1])) {
    return $match[1];
  }
  preg_match("#\[".$config['language_dir_default']."\](.*)(\[\/?".$config['language_list']."\]|$)#iDUs", $text, $match);
  if (!empty($match[1])) {
    return $match[1];
  }
  if ($show_first) {
    preg_match("#\[".$config['language_list']."\](.*)(\[\/?".$config['language_list']."\]|$)#iDUs", $text, $match);
    if (!empty($match[2])) {
      return $match[2];
    }
  }
  if ($remove) {
    return preg_replace("#\[".$config['language_list']."\](.*)#iDs", "", $text);
  }
  return $text;
}

This little change - the 'definition' of a [default] language tag, solved for me two problems:
1. I can sort my pictures.
2. I can define text in a default mode, which is taken, if the choosen language is not present in the text.

Example:

A picture with the name: [001][default]Picture[deutsch]Bild will be shown in any language
(except german) as 'Picture' and in german as 'Bild' and the prefix [001] is used to sort my pictures within a category.

As a sorting criteria you can use everything with '[]' at the beginning... of course execpt any installed language-name


I don' know, if anybody else will find this useful, but anyway  :wink:

Cheers
HoSt



Pages: 1 2 [3]