Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by bytesource

  1. As it turned out, the issue was with the database. For every repeater item, I deleted the translated text, saved the page, re-entered the text and saved the page again. After that the text magically appeared on the page. I also removed the repeater at the top and replaced it with a simple image field. In summary, I was able to solve the issue, but I still don't know what caused it in the first place. Cheers, Stefan
  2. @LostKobrakai Please find below the code for all three repeater sections, together with some additional explanations. Section: Hero Image ============================================== Partial home-large-image.php (gets included by template home.php) $img = $page->slides->first()->image; slides: Repeater with a single Image field ('image') Note: Throw the error "Calling a function on an non-object" Section: OUR STRENGTHS / NUESTRAS FORTALEZAS ============================================== Template home.php <?php foreach ($page->portfolio as $p): ?> <?php echo $p->render(); ?> <?php endforeach; ?> Template repeater_services.php (Template of repeater portfolio) <div class="col-md-4 col portfolio-item"> <div class="icon-border"> <i class="glyphicon <?= $page->icon ?>"></i> </div> <!-- <h3 class="upper colored"><?= $page->subject ?></h3> --> <h3 class="upper colored"><a href="<?= $page->page->url ?>" ><?= $page->subject ?></a></h3> <?= $page->summary ?> <?php $linkText = __("Main page"); echo "<a class='go-to-link' href='{$page->page->url}'>{$linkText} <i class='glyphicon glyphicon-new-window'></i></a>"; ?> </div> portfolio: Repeater with the following fields -- TextLanguage ('subject') -- TextareaLanguage ('summary') -- Page ('page') -- Text ('icon') Note: This repeater is supposed to display three repeater items. Today a single one suddenly appeared (the second one of the three). Section: YOUR ADVANTAGES / SUS VENTAJAS ============================================== Template home.php <?php foreach($page->all_advantages as $advantage) { echo $advantage->render(); } ?> Template repeater_competitive_advantages.php (Template of repeater all_advantages) <div class="<?= evenOddTimeline() ?>"> <div class="icon-border"> </div> <h5 class="upper"><?= $page->subject ?></h5> <?= $page->summary ?> </div> all_advantages: Repeater with two fields -- TextLanguage ('subject') -- TextareaLanguage ('summary') Note: This repeater is supposed to display five repeater items, however, none is displayed. Final note: All three repeaters work properly on the English version (default language) of the home page, but not on the Spanish version. Cheers, Stefan
  3. Replacing the repeaters with pagetables would be possible, but that would only be my last choice. I was just hoping that I would be able to find the reason for this weird behavior. Cheers, Stefan
  4. I just updated my site to PHP version 5.6, the newest version available with my hosting provider: http://www.sovonex.com/phpinfo/ Unfortunately, still no repeaters (except for 1 element of 1 repeater) are displayed on the homepage of the Spanish version: http://www.sovonex.com/es/ Is there anything else left to check? Cheers, Stefan
  5. Thanks for your additional ideas. I looked at the forum pages you linked to, but I don't think this is the issue here. The image in question is about 350kb and is displayed just fine on the English homepage (just not on the Spanish one). This same is true for the other repeaters. I flushed ProCache's cache but that did not have any effect on the issue. I am not aware of any other cache. Also, all updates to all other pages did appear without problems. I know how to set the language of a page to 'active', but I haven't heard of a similar setting for repeaters. So I guess I am back at square one for now. Cheers, Stefan
  6. After logging in to the admin and reloading the page, one repeater element (out of 3) under the headline "NUESTRAS FORTALEZAS" is now displayed. But the content of the other repeaters still does not appear. And I have no clue how this single repeater element suddenly appeared on the page. I extended the execution time of the home template with set_time_limit(600); but this did not did the trick, either. Nor did flushing the cache. This is the PHP info file from my hosting provider: http://phpinfo.he-webpack.de/phpinfo.php I uploaded the database via PHPMyAdmin and the content through the upload site of my hosting provider. Cheers, Stefan
  7. Does anybody have any idea what might be causing the issue here? The real problem for me is that I don't know where to look at next. Cheers, Stefan
  8. Hi, I have been dealing with a weird issue, where repeater fields are not displayed under the following specific conditions: Repeaters are displayed on all pages of the default language, but not for any other language Only repeaters on the home page are affected, repeaters on other pages are displayed just fine in all languages. This problem only occurs on the production sever. Everything works find locally. This is the page in question: www.sovonex.com/es/ And this is the English (default language) page for comparison: www.sovonex.com The image at the top is part of a repeater and called like this: <?php $img = $page->slides->first()->image; echo $img->render(array('class' => 'responsive-image')); // render() is a custom hook that deals with responsive images and lazy loading I had to disable the output of the image, otherwise the page would not have loaded at all ("Calling a function on an non-object"). However, what you can see is that the two section below "NUESTRAS FORTALEZAS" and "SUS VENTAJAS" that get their content from repeaters, don't show any content, either. The fact that the issue only occurs on the production server indicates that some permissions are off, but I already checked every file, and to the best of my knowledge everything is fine. EDIT: Even if there was a problem with the file permissions, it should not matter in this case, as the content for repeaters lives in the database and is not stored as an asset in the file system. At least this is how I understand it. The Spanish version of the site will be ready in a few days, but it won't provide a good user experience with the repeaters not showing. I have been struggling with this issue for almost a month now, and also posted it here (1), but I still haven't found any solution. I therefore would be very grateful if anyone could give me a hint or point me into the right direction. Cheers, Stefan (1) www.processwire.com/talk/topic/11300-problem-with-repeater-fields-in-multi-language-pages/
  9. I can finally confirm that the /assets/ folder is writable, but still the repeater contents are not showing on non-default language pages. Honestly, I have no clue what to do next, so any ideas are highly appreciated. Cheers, Stefan
  10. I had another issue with an image description that wouldn't get saved on the production server, and this turned out to be due to insufficient folder rights. I am suspecting the same to be the case with the content of repeaters not showing up on the production server. I therefore would like to ask if there is some folder under /assets/ or somewhere else connected to repeaters that I could check. For the record, I recursively gave 777 permission to the /assets/ folder, but the program my hosting provider uses doesn't seem to work, as it also did not change the permissions of the image mentioned above. Cheers, Stefan
  11. I am having the same problem where repeater fields are not displayed on a page if the active language is not the default language. Even more strange, everything does work on my local installation, but not on the server. There must be some reason for this, but I just cannot find it. Any suggestions as to how to test this issue are highly welcome! Cheers, Stefan
  12. @mr-fan You solved the issue! Thanks to you mentioning other textformatters I took a closer look at the body field, where the Hanna code was to be applied to - only to find out that the HannaCode textformatter was applied after the textile textformatter. Switching both resolved the issue immediately! Best regards,
  13. In case this is important: I am currently running Proccesswire version 2.6.1 and HannaCode version 0.1.9.
  14. Hi, I wrote some simple Hanna code for outputting external links given an identifier and a link text. The actual link URL is stored in a repeater field along with a unique id. Example usage: [[link id=myid text="My Great Link"]] Default attributes: id text target=_blank Code: <?php $link = $pages->get("template=repeater_links, identifier={$id}")->link; echo "<a href='{$link}' target='{$target}'>{$text}</a>"; ?> The problem is that the value of the text attribute ("My Great Link" in the example above) gets cut off at the first whitespace ("My). From the module description I learnt that in order to pass a string containing blank characters, all I needed to do was put quotes around the attribute. However, it seems I am still missing something, and it would be great if someone could point me to the right direction. Cheers, Stefan
  15. I am sorry, but this was a false alarm. Only today did I realize that I was extracting the descriptions from another page than I thought. This other page is a dummy page whose image description fields were indeed all populated with the value "original".
  16. Thanks for pointing me to that piece of code. So, instead of $text = $file->description; I tried $text = $file->description(); as well as $text = $file->description($defaultLanguage, null); as well as $text = $file->description($defaultLanguage); But in each case I still only got the string "original" back. I also wonder where this string might come from. At least it does not appear in the Pagefile source code. Cheers, Stefan
  17. Hi, I as part of an implementation that extracts the strings from all translatable language fields, the following code section retrieves the description value from all files and images: <?php $currentPage = $page; $currentPage->setOutputFormatting(false); $pageFields = $currentPage->fields; // iterate through all fields of a page foreach ($pageFields as $field) { $type = $field->type; // FieldtypeImage is a subclass of FieldtypeFile, // but for clarity we separate both types here. if ($type == "FieldtypeImage" || $type == "FieldtypeFile") { $fieldName = $field->name; // for all images, retrieve the text value from the 'description' field // From the file/image field type settings page: // "When output formatting is off, the value is always an array (WireArray)."" // So, with output formatting set to 'false' in getDefaultValues(), we can use // 'foreach' on all fields, even if the value for 'Maximum files allowed' was set to 1. foreach($currentPage->$fieldName as $file) $text = $file->description; // sample output echo $text; } // checking for other field types and extracting values } ?> The problem is, regardless of whether a description value was set or not, all that is returned is the string "original". I wonder if anyone might have an idea of what is going on here. Cheers, Stefan
  18. Hi, I want to retrieve via the API all translation files for /site/ that I manually selected on the page /admin/setup/language-translator/add/ (please see the attached screenshot). I do not want the JSON files, I only need the textdomain representation of each of these files, so that I can call methods of the LanguageTranslator class class on them. The problem is I am not sure how the manually selected texdomains are distinguished from all other textdomains, so I am not quite sure how to approach this problem. Just for reference, below is the code I wrote for retrieving all untranslated text strings from a single textdomain. Now I want to do this for all textdomains/files that I selected a described above. // $filename: path from site root to file to be parsed // $translator: instace of LanguageTranslator for target language // returns array(hash => array(textdomain, text, comment), ...) function getUntranslatedStaticFromTextdomain($filename, LanguageTranslator $translator) { $parser = new LanguageParser($translator, $filename); $realUntranslated = array(); $comments = $parser->getComments(); // Note: getUntranslated() returns ALL phrases (in the default language), // even if already translated. // So we need to filter out all translated phrases. foreach ($parser->getUntranslated() as $hash => $originalText) { $textdomain = $translator->filenameToTextdomain($filename); $tdObject = $translator->getTextdomain($textdomain); // if no translation is present, has is not set. $hasTranslation = isset($tdObject['translations'][$hash]['text']); if(!$hasTranslation) { $comment = isset($comments[$hash]) ? $comments[$hash] : ""; $realUntranslated[$hash] = array( 'textdomain' => $textdomain, 'text' => $originalText, 'comment' => $comment ); } } return $realUntranslated; } Maybe someone has done this before and could point me into the right direction. Cheers, Stefan
  19. I am glad you mentioned pass by reference. As the file is part of an array I made a small test: <?php $arr = array("Tom"); $value = $arr[0]; $value = "Jerry"; echo $arr[0]; // => Tom $arr[0] = $value; echo $arr[0]; // => Jerry ?> As it turns out, the original array element did not get changed at all. So I replaced the old file with the one that was changed and now the translation appears in the admin: <?php // $translations: array of id => translation key/value pairs // $language: string determing the target language, such a 'de' or 'pt' function insertTranslations($translations, $language) { $translations = mergeSections($translations); foreach($translations as $id => $translation) { // example ID: // 1335··1335··FieldtypeImage··images··03.jpg··1of1 list($refPage, $page, $type, $name, $identifier) = splitID($id); if ("FieldtypeImage" === $type || "FieldtypeFile" === $type) { $p = wire('pages')->get($page); $p->setOutputFormatting(false); $field = $p->$name; $file = $field->getFile($identifier); $targetLanguage = wire('languages')->get($language); $file->set("description$targetLanguage", $translation); // replace old value with new one $field[$identifier] = $file; $p->save(); } // [...] } } Thanks a lot for your help! Cheers, Stefan
  20. Does anybody have any idea of why the language value set for the image description field does not show up in the admin?
  21. Thanks for this overview! Doing a little bit of testing, I found that the language value actually gets set, but for some reason it does not get saved. Here is the the original code with some extra lines added for testing: // $translations: array of id => translation key/value pairs // $language: string determing the target language, such a 'de' or 'pt' function insertTranslations($translations, $language) { $translations = mergeSections($translations); foreach($translations as $id => $translation) { // example ID: // 1335··1335··FieldtypeImage··images··03.jpg··1of1 list($refPage, $page, $type, $name, $identifier) = splitID($id); if ("FieldtypeImage" === $type || "FieldtypeFile" === $type) { $p = wire('pages')->get($page); $p->setOutputFormatting(false); $field = $p->$name; $file = $field[$identifier]; // added for testing only $sourceLanguage = wire('user')->language; $translation = "This is a translation"; // --------------- $targetLanguage = wire('languages')->get($language); $file->set("description$targetLanguage", $translation); // for added testing only echo $file->get("description$targetLanguage") . "</br></br>"; // => "This is a translation" echo $file->get("description") . "</br></br>"; // => This outputs the original string set for the default language in the Admin // --------------- $p->save(); } // [....] } } So, the language value gets set properly, but it does not appear in the admin. As I already called $p->save(), I am not sure what I might have missed. Language values for fields of type FieldtypeTextLanguage and FieldtypeTextareaLanguage that are also set in this function by calling setLanguageValue() do appear in the admin. Again, any ideas are highly welcome! Cheers, Stefan
  22. Thanks for pointing me to the implementation of the Pagefile::set() function. I went through my function again, but couldn't find any errors. Of, course, this does not mean there aren't any. It is just that setting the language values for all other language fields, such as TextLanguage and TextareaLanguage using the setLanguageValue() function does work as expected. To get a better understanding of what I am actually dealing with here, I would like to know how FieldtypeImage (or FieldtypeFile) is represented internally. I read that images bound to the type were represented as an array. But what kind of array items are these exactly? In other words, if I have an image field containing three images, what is the field type of each image? Cheers, Stefan
  23. Hi all, I have been wondering how to set the value an an image's description for another language. The following code did not work: <?php // $translations: array of id => translation key/value pairs // $language: string determing the target language, such a 'de' or 'pt' function insertTranslations($translations, $language) { $translations = mergeSections($translations); foreach($translations as $id => $translation) { // example ID: // 1335··1335··FieldtypeImage··images··03.jpg··1of1 list($refPage, $page, $type, $name, $identifier) = splitID($id); if ("FieldtypeImage" === $type || "FieldtypeFile" === $type) { $p = wire('pages')->get($page); $p->setOutputFormatting(false); $field = $p->$name; $file = $field[$identifier]; $targetLanguage = wire('languages')->get($language); // get the language we want $file->set("description$targetLanguage", $translation); $p->save(); } } // [...] } Any suggestions are highly welcome! Cheers, Stefan
  24. BitPoet, Thanks for your help! That is exactly what I was looking for. Cheers, Stefan
  • Create New...