Jump to content

Inxentas

Members
  • Content Count

    29
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Inxentas

  1. No, I simply moved them to a local directory, hoping that would be sufficient. Uploading them via the admin seemed to work, thank you! I'm still curious as to what is the difference (what uploading them via the admin actually does apart from storing the file). I could not find a "translation" system template, did you perhaps mean the language_files_site system Field? That one seems to have an option to allow for overwriting files.
  2. A client of mine wants his translations being done by an external agency. I've showed them the Site Translation Files and they can deliver me the required translations in the same JSON format. I went about it by first making some translation files for each language, so there's an ID and all the fields get an identifier. The intent is to give them the file, they change the content, and we place those files back. From there I've done some testing and it appears we could simply change the content of these files, as long as the JSON format is being respected. Whenever I changed something, the translation worked properly. So I sent a JSON file to the translator and had them translate the strings. There's no stuff in there that needs escaping so I figured this should work properly. At first they screwed up the values in the "file" and "textdomain" properties of the JSON object, but we fixed that. However, when I place the file in it's appropriate folder I get the following error: Fatal error: Uncaught TypeError: Argument 3 passed to ProcessWire\LanguageTranslator::textdomainTemplate() must be of the type array, null given, called in C:\wamp\www\bamboobrands.com\public_html\wire\modules\LanguageSupport\LanguageTranslator.php on line 485 and defined in C:\wamp\www\bamboobrands.com\public_html\wire\modules\LanguageSupport\LanguageTranslator.php on line 137 TypeError: Argument 3 passed to ProcessWire\LanguageTranslator::textdomainTemplate() must be of the type array, null given, called in C:\wamp\www\bamboobrands.com\public_html\wire\modules\LanguageSupport\LanguageTranslator.php on line 485 in C:\wamp\www\bamboobrands.com\public_html\wire\modules\LanguageSupport\LanguageTranslator.php on line 137 When I delete the JSON file the error goes away so I'm quite sure it's the file causing the issue. I did the following test: Deleted the language file and remade it via Find Files To Translate. Copied the file's content into a new JSON file. Overwritten the language file with this new JSON file. The same error occurs. I've confirmed with DiffChecker that the files are 100% identical. Somehow this issue only occurs when I overwrite the file. I seem to be able to copy-paste the data in, but using a different file causes above error. What could be causing this? Encoding maybe? I couldn't get the translator's file to work, but I could paste their work into the file. (I've told my client translation is an maintenance issue because his content will keep changing anyway. He is adamant that we do it this way, disregarding the fact that pasting in his translations would be less work then working around any coding issues. I know it's kind of stupid and error-prone to do it this way).
  3. I have a big collection of Pages with a template called page-product. These products have a few fields describing their properties. Now my client wants to split this template into various types of products, each with their own set of properties. The most obvious solution would be to make a few new specific templates, like page-product-foo or page-product-bar. Doing this would also mean rewriting a lot of existing selector logic. So what I could also do, is allow the client to append a child to the Product that has these properties. For me that would be a good solution, but for my client this might be confusing. So I'm looking for a user-friendly way to do the same. Ideally, these Properties should be filled in when editing a Page without having to mess with it's Children. One option is to make a Page with children for each type of product and make it a dropdown. And subsequently have each "property" field be visible only when a specific product-type is chosen. However, I'm not sure if this is the best way to go about it - since at the frontend I'd have to take these fields into account, and I'm not sure whether I'll be able to deduct in code which field should be shown (I guess this could be pulled from $fields->MyFieldName). Does anyone have a better idea on how to implement such a feature?
  4. Thanks guys, but I'm indeed aware how Google works 😃 and had hoped to find a less hacky way of doing things then straight up SQL. The weird this is that when I try to collect the language setting from a user via a selector and $pages, I don't get the actual field value - I get the value in the $user object instead. Something that works around this would also work well for me.
  5. I'm updating a website that is about a year old. The site has two languages: Dutch (default) and English. Now the clients wants English to become the default language. The site has a ton of translations already, so changing the default language in the backend is not really an option. So I'm looking for a way to simulate that behaviour, but in my experience doing it with redirects will lead to messy and unwanted behaviour. Can anyone tell me what the proper way of doing this is?
  6. Hi there! I am making a webapp where the admin can create Surveys, Questions and Answers. These are all Pages with a normal Parent / Child relationship. I want to prevent the admin from making changes to a Survey or it's children as soon as the submissions roll in. For that purpose I am using this code inside a hook, which basicly checks what template the soon-to-be-saved page is. I then find the proper Survey and check whether we have submissions for that Survey in an external table: public function testSave($event) { $page = $event->arguments('page'); $survey = null; switch($page->template->name){ case 'survey': $survey = $page; break; case 'question': $survey = $page->parent; break; case 'answer-choice': case 'answer-open': case 'answer-rating-1-10': case 'answer-rating-1-100': case 'answer-rating-likert': $survey = $page->parent->parent; break; } if ($survey) { $res = $this->db->query("SELECT * FROM submissions WHERE surveyId = " . $survey->id); if($res->num_rows > 0){ $this->error("There are already " . $res->num_rows . " submissions for " . $survey->title); } } } Works like a charm, with one exception. I do wish to prevent the page from being saved, but throwing an error doesn't prevent this. It doesn't seem to matter how I implement this in my module's init() method. These two lines of code have the exact same effect: the red warning appears, but values are still saved. $this->pages->addHookBefore('Pages::save', $this, 'testSave'); $this->pages->addHookBefore('Pages::saveReady', $this, 'testSave'); Is there a way to tell ProcessWire to NOT save the page when a certain condition is met? Thanks for your future replies!
  7. If the server would have a classic timeout on a foreach() it wouldn't serve the page at all... but it does. I'll check the logs as soon as I have access again. Hosting company changed it's control panel... I'll check that module! It goes a bit against the intent of the application to be dependent on superuser actions, but at the very least I learn a few more tricks. I also uploaded a bulk of images on the local server. This one behaves more natural. The first request I do times out due to trying to compress 303 images in a single request. When I do a second request, many images are already compressed so eventually it doesn't time out anymore. This is acceptable. It seems there's some artificial limit on the live server or something.
  8. I have an image gallery based on an Image field with about 300 images in it. That caused a little issues with uploading, since it's on a shared host I had to do that piecemeal in order to not overload the server. I kept refreshing the frontend of that page to make sure the server doesn't run out of memory compressing the images, as such an amount obviously requires thumbnails. After 160 images the frontend no longer updates. I can add images to the backend, but they are not shown on the frontend. The images field is not limited in any way. Is there a cap to the amount of images uploaded to a single field? Or any other aspect that might explain such behaviour? The images show up fine in the backend, but when I foreach() through that field I only get 160 results. Any idea what might be going on?
  9. Hello there! I have a question about translations in external files. I remember a topic I started about a year ago about the subject, but I can't find it at the moment. In that topic I had some issues getting translations to work in PHP includes in templates. The solution was the way these files were included. Now I have a similar problem, but it's a bit different. So far I've been able to let external files communicate with the ProcessWire API by including the index file. Imagine that you'd make a folder named ajax in the site folder. Any AJAX script stored there can access the $pages variable. If you set the user language ($user->language) you can even get the translated fields without issues. However, I don't seem to be able to work with translated files. Whenever I include the index file... include_once('./../../index.php'); I can access fields without problems, they even translate properly... $example = $pages->get('/example-page-url/')->example_field; But when trying to access a file based translations, I get some weird inconsistent behavior. Whenever a string is surrounded by the translation method, it is found in the backend, but not translated, even when the users language has been set to the required language: _('This string is recognized, but not translated.') Secondly, when I happen to include another file in that file, translatable phrases are no longer recognized unless I put an extra underscore in the method name: __('I have no idea why, but only like this does the backend recognize me.') Phrases found in this way are also not translated, in fact they cause an error due to the method "__" not existing. Note, those are two underscores. I am at a loss why this behaviour takes place. Does anyone know what I could be doing wrong? To summarize: translations in external AJAX scripts that include the index file, are recognized by the backend but not actually translated. whenever these files include other files, translation behavior get weird. The method requires an extra underscore for the phrase to be found, but logically this causes an error.
  10. Amazing how simple ProcessWire stuff can be to implement! Having no fall back is fine, but thanks for that heads up.
  11. Wow, thanks for your speedy reply @BitPoet! This worked like a charm. I didn't realize the input class was only required for templates. Will this play nice with multi language websites, by the way? I might was well implement multi language support right away.
  12. Hi there! I'm writing a module for a website, and it needs to store a bit of text. This works fine: $inputfields = parent::getInputfields(); $message = $this->modules->get('InputfieldTextarea'); $message->attr('name', 'message'); $message->label = 'Message'; $message->required = true; $message->set("inputfieldClass", "InputfieldCKEditor"); $inputfields->add($message); ...except the part about the inputfieldClass. Is it possible to make these fields have a "CKEditor" instead? My client would need to add a little markup.
  13. I'm sorry but I updated my entire website, so this link is no longer active.
  14. mel47'suggestion should work. Remember to put setlocale() in your config. A fresh PW installation should remind you of this. http://php.net/manual/en/function.setlocale.php You might be interested in making the <HTML> tags on your website obey the locale as well. https://www.w3.org/International/questions/qa-html-language-declarations
  15. Why not... make a Template for months with a title (Januari-December) and index (1-12) field. Then make 12 pages with this template representing each month. make a Field (month) of the Page type. Configure it to accept only 1 choice of the template we made for the month. Voila, a translatable month picker! make a Field (year) which can be an Integer with a minimum and maximum value of your choice. This way you are 100% sure that the input of your client is clean without having to mess with a regex. The downside is that it requires two fields instead of one, and some data management. I find that permissable as you explicitly don't want to store a full datetime. You could configure the template that contains these Fields to display them next to another at 50% width to show the user their intent to be used together. Consider making these fields required.
  16. I did a develop and made dis, a procedural galaxy that, well... gets procedurally generated. You can use your mouse to zoom in/out and look around. You can click on stars to get their specific information. It's inspired by the galaxy maps found in games like Elite Dangerous and Eve Online. http://fransvanberendonk.com/procedural-galaxy/ Basicly I've made Templates and Fields for Spectral Classes and Subclasses, and looked up online what a realistic distribution scheme would be for these. This data is grouped under a page that renders then as JSON for the Javascript application to work with. I wrote that app in AngularJS, so I could add more controllers to it later. It also uses BabylonJS to calculate the number and position of stars and display them on screen, and assigns each a Spectral Class and Subclass after some shuffling of the dataset. Using a secondary controller only used in a ProcessModule for the CMS, I can broadcast events that redo the procedure using different variables (see screenshot below). No particular purpose, just thought I'd share a cool side project that rolled out of my exploration of these JS frameworks in conjunction with PW.
  17. Congrats on account of your first page going live! I like your responsive layout.
  18. I found this while looking around: https://processwire.com/blog/posts/august-2014-core-updates-1/ Seems what I'm after is how to properly use the setImportData() method.
  19. When you edit your field, below Input you can find the Date Input Format. Normally you'd set that to Y-m-d or d-m-Y if you use it at all. However, when you set it to m-Y or Y-m then the day will not be saved in the field. Unfortunately, the picker itself won't change to reflect this behaviour. You also still have to click on the day to update the field itself. I'm not aware of methods to change the picker itself without changing it's code.
  20. I love the option to export fields via the CMS, and wondered about using that export data in a module. Basicly, I'd want to configure a field using the CMS and then paste it's export data in the module code as a string, or save it in a seperate file I can read from the module code. Once I have that string as a variable or file, I'd want to run the same code the import option does... but then from my module code's install method! Is that possible? It would save a lot of time configuring fields through the API.
  21. Thanks guys, but it turned out to be some configuration error on the hosting side (Allow/Override). All is well now!
  22. It's enabled, as far as I can see. I've asked my host to take a look at the issue as well. Since others report that with certain modifications they are able to see ProcessWires' default 404 page, I've asked them to check if .htaccess is ignored for some serverside reason.
  23. I've got several Processwire websites running on a local server and an external server. With one of them I have the migration issue where anything but the homepage serves a 404 error. I've read pretty much all topics about the problem but can't seem to find a solution that works. Now in my situation, I request a new virtual domain (oisterwijk-cultuur.nl) for each website, and set an A record on our own domain (mallens-markhorst.nl). The end result: http://oisterwijk-cultuur.nl.mallens-markhorst.nl/ So far so good, but only the homepage works. Subpages and the admin URL generate a 404. Most of the topics I read revolved around changing .htaccess but I've got similar websites running on the same testing server without any modifications. Example: http://moor-oisterwijk.nl.mallens-markhorst.nl/ I've checked the .htaccess file line by line and even copied the one from working website into the non-working one, but to no avail. I tried upgrading PW but that didn't help either. Uploading and accessing a php file works, and mod_rewrite is on. Link to phpinfo() result. The document root in my FTP client is as follows: /data/www/oisterwijk-cultuur.nl.mallens-markhorst.nl/public_html I've tried uncommenting and changing the RewriteBase lines, tried both the full path as just '/public_html/', but unlike others there doesn't seem to change anything for me. I get the same plain 404 every time. Any ideas on what else I can try? Apart from a fresh installation? EDIT: I've just did a fresh install of PW 3.0.72 on the virtual domain, and it seems to have the same problem, I can't load the admin url.
  24. As usual, it was a very simple method I didn't think of myself. Thanks a lot! I modified my selector like this: $selector = ''; if ($input->template) { $selector .= 'template=' . $input->template; } else { $selector .= 'template='.$templates->find("contentType=json"); $selector .= ",template!=data-json"; $selector .= ",children.count=0"; } if ($input->start) { $selector .= ',start=' . $input->start; } if ($input->limit) { $selector .= ',limit=' . $input->limit; } if ($input->sort) { $selector .= ',sort=' . $input->sort; } $foundPages = $pages->find($selector); First line does what I just asked: it filters the pages by their template's Content Type. Second line makes sure I exclude the current page's template itself. Third line ensures I grab only the "leaves" of the page tree, and none of the "branches".
  25. Hi there! I've got a question about selectors. I'd like to know if it's possible to use a selector to find pages based on the Content-Type of their specific template. I'd like to use a selector to find all pages that have a template with an "application/json" Content-Type, if such is possible. Here's the PHP code I'm using for the template that should output my data. The idea is that you can filter, sort and limit stuff using URL variables. Right now, "template" must be specified in the $input variable, or else the json output gets corrupted by the HTML (returned by the render() call on pages with a "text/html" Content Typed template). I only wish to grab the pages that have a "json/application" Content Type if the "template" input value is empty. <?php header('Content-Type: application/json'); $selector = ''; // TODO: start with Content Type filter if ($input->template) $selector .= ',template=' . $input->template; if ($input->start) $selector .= ',start=' . $input->start; if ($input->limit) $selector .= ',limit=' . $input->limit; if ($input->sort) $selector .= ',sort=' . $input->sort; $pages = $pages->find($selector); $n = count($pages); $output = '['; ?> <?php for ($i=0; $i<$n; $i++) : ?> <?php $output .= $pages[$i]->render(); ?> <?php if ($i < $n-1) { $output .= ','; } ?> <?php endfor; ?> <?php $output .= ']'; echo $output;
×
×
  • Create New...