• Content Count

  • Joined

  • Last visited

Community Reputation

15 Good

About LAPS

  • Rank
    Sr. Member

Recent Profile Visitors

350 profile views
  1. Hi, in my template file I state the following code: // File: template_name.php $files->include('path/to/filename', array( 'key1' => "Some text value 1", // e.g. $page->title 'key2' => "Some text value 2", // e.g. $page->getLanguageValue('default', 'title') 'keyN' => "Some text value N" )); In path/to/file_name.php I state the following code: // File: path/to/file_name.php $key1 = $vars['key1'] | "Default1"; $key2 = $vars['key2'] | "Default2"; $keyN = $vars['keyN'] | "DefaultN"; // ... echo $key1 . "<br>"; echo $key2 . "<br>"; echo $keyN . "<br>"; // ... When I render the above code in the front-end then I get the text values changed! That is, it outputs something like the following: Rdfs~{{ value1 GDdfgsd value2 dfd]~df value3 Am I doing something wrong? Update In path/to/file_name.php just use ?: instead of |, this way: // File: path/to/file_name.php $key1 = $vars['key1'] ?: "Default1"; $key2 = $vars['key2'] ?: "Default2"; $keyN = $vars['keyN'] ?: "DefaultN"; // ... echo $key1 . "<br>"; echo $key2 . "<br>"; echo $keyN . "<br>"; // ... PHP matters...
  2. LAPS

    First of all, thank you for your module. I'm using the PW FormBuilder module embedding forms in <iframe> HTML tags. When a user accesses for the first time the page that has an "iframed" form then the user sees two EU-Cookie-Law messages, one under the page (BTW I set the EU-Cookie-Law message position to bottom) and one under the form (BTW This causes the message to override the submit button). I'd like to do not show the EU-Cookie-Law message under the "iframed" form but only under the page. How can I make that (e.g. by using selectors for the "iframed" form-page)? Update Perhaps I found a solution: I think the first solution is better than the second one... but how will this affect the performance of the web site (if it will do)?
  3. Hi, I've a multi-language text field which label is overridden in the template to "Label English" and "Label Italian". I'd like to output the overridden Italian version when accessing the link I tried the following without success: // output a blank value $page->text_field_name->label; $page->get('text_field_name')->label; // get the error: "Error: Call to a member function getLabel() on string" $page->text_field_name->getLabel(); $page->get('text_field_name')->getLabel(); // output the not overridden, translated value $page->fields->text_field_name->label; $page->fields->text_field_name->getLabel(); $page->fields->get('text_field_name')->label; $page->fields->get('text_field_name')->getLabel(); How can I output the label overridden in the template? Update I ended up using: $page->fields->getFieldContext('text_field_name')->getLabel(); Is it the correct way to get the overridden, translated label? Or is there some better?
  4. Hi, I've the function: function functionName(Page $item) { // function code } If in templates I use the code functionName($pages->get($id)); then in the logs I get the error "Argument 1 passed to functionName() must be an instance of Page, instance of ProcessWire\Page given, called in ...". However I don't get the error by removing the Page type from the function statement. Why does it happen?
  5. I enabled multi-language support in my website and I am looking for a easy way to output page values (e.g. throughout an entire .php file) in a desired language without using $page->getLanguageValue('default', 'title')everytime I need to output a page value. I thought of finding a page in a given language by using something like $pages->findOne($id, ['language' => 'italian']) or setting someway a "language context". What do you thing about? How can I make that?
  6. Hi, I'm translating my website (in particular, FormBuilder template files) using Code Internationalization (i18n). When I use this code: <?php echo sprintf(__('Some text and <a href="%1$s">link</a>'), ''; ?> then it outputs plain text: Some text and <a href="">link</a> How can I output the above string this way (no plain text): Some text and link? Update I will use html_entity_decode(). What do you thing about?
  7. How do you translate the string? That is, where do you put English and (in my case) Italian strings (I see only the English one in file /site/translations.php)? What do you think about this solution?
  8. Hi, I've successfully installed and used Language Support & Co. and Functional Fields modules so that I can translate almost all the strings of my website in English (default) and Italian. Now, in my template files I've "See also" strings that I would like to translate globally (not per template by using Functional Fields). How should I make this? I read the doc and maybe what I need is to use the textdomain, but I didn't understand how to use it. That is, what text/code should be in the file? any example? Also, in the admin area I have the menu items Default and Italian under Setup > Languages. Once accessed one of them, there is the field "Site Translation Files" with the description: "Use this field for translations specific to your site (like files in /site/templates/ for example)". Should I use this field (instead of textdomains) to set globally translated strings? If so, what text/code should be in the file? any example?
  9. By using an array to define module configuration (PW new module configuration) I partly solved the issue of configuring the Page Reference field because data is not saved: array( 'name' => 'selectedPages', 'type' => 'page', 'label' => $this->_('Selected pages'), 'description' => $this->_('Selected pages description).'), 'inputfield' => 'InputfieldCheckboxes', 'derefAsPage' => 0, 'collapsed' => 0, 'optionColumns' => 0, 'labelFieldName' => '.', 'labelFieldFormat' => '{name}', 'findPagesSelector' => 'template=named-template, include=all', 'allowUnpub' => true, 'required' => true, 'defaultValue' => 1985, 'notes' => $this->_('Selected pages notes'), // I tryed to set value to '', [] and $this->selectedPages without success 'value' => ???, ) How should I configure the page checkboxes field to store data submitted from the module page? Update: I found a possible solution here.
  10. @bernhard, thank you for remembering me to use Tracy Debugger. Assuming the Tracy field settings and field code panels that you mentioned are in the "Request info" tab, when I expand the "Field List & Values" link in it, then it doesn't list the Page Reference field that in my case is not working (the field shows the error message above). In fact, only 'title' and 'process' fields are shown.
  11. I'm developing a module that has a configurable Page Reference field. For this page field, I would like to set some options via API. Here are these options as they are shown in the admin area: Details > Page field value type set to "Multiple pages PageArray". Input > Selectable pages > Template set to "template-name". Input > Selectable pages > Label field set to "Custom format": "{title} {summary}". Set initial values (see below). In my module file PageSelectionModule.config.php I have: class PageSelectionModule extends ModuleConfig { public function __construct() { $this->add(array( // Page field: selectedPages // Note: By using this code, in the module page I get the error message: // "This field needs to be configured before it can be used". array( 'name' => 'selectedPages', 'type' => 'page', 'label' => $this->_('Selected pages'), 'description' => $this->_('Selected pages description).'), 'value' => ???, 'required' => true, 'notes' => $this->_('Selected pages notes'), ) )); } } My questions are: How can I set the above page field options via API in the module? Is the 'value' handled (stored and retrieved) internally by PW? Where I can find some documentation about all this?
  12. I'm using ProcessWire 3.0.98 and I'm trying to understand because the user cannot view the uploaded image in the Edit Profile page (even if the image upload seems to be successful since the related file is uploaded to the /site/assets/files folder of the website). In Edit Profile I get a "blank" image: and also in the frontend when outputting it: Update In file config.php I have set $config->pagefileSecure = true; and if I remove this then the profile image field works as expected. However I need this config enabled since I prevent access to files of access protected pages throughout all the website. Furthermore, for the user template the option "Do you want to manage view and edit access for pages using this template?" under "Advanced" tab is set to "No", so I expect the file to be accessible. However, the user template has not template file (user.php). What should I do in order to keep things consistent? BTW @Zeka, in your linked post I have not posted.
  13. Are there some updates about issues with making images to be edited by the user in their own profile (admin area)? I'm in trouble with it. What I made is: In the 'user' template, I added an 'images' field. In the 'role' page (designating users allowed to edit their profile), I checked/enabled the 'profile-edit' permission. In the 'ProcessProfile' (User Profile) module, I checked/enabled the 'images' field. What happens is: when the user goes to the page /processwire/profile/ (admin area) then the image upload seems to be successful but the user cannot view the uploaded image. Is there something I'm doing wrong?
  14. To remove the 'pass', 'email', 'roles', and 'language' fields from the user_copy template, I had to temporarily disable their "system" and "permanent" statuses for each field by unchecking the related options in the Advanced tab of Edit Field. After this, I was able to complete the step 3 successfully.
  15. When I manage to remove the 'pass', 'email', 'roles', and 'language' fields of the user_copy template and save then I get this error message: The only field I have been able to remove was the 'admin_theme'.