Jump to content

Juergen

Members
  • Posts

    1,306
  • Joined

  • Last visited

  • Days Won

    13

Everything posted by Juergen

  1. Yes that was the problem (Hint: This code is for multilingual site): You have to insert the following code to get the values in different languages: if ($user->language->name != 'default') { $title = "title{$user->language}"; $value = "value{$user->language}"; } else { $title = 'title'; $value = 'value'; } Then you can start to create the options for the select $storedgender = $user->YOUROPTIONFIELDNAME->id; $genderoptionstag = ""; //make select for gender options $genderoptions = $fieldtypes->get('FieldtypeOptions')->getOptions('YOUROPTIONFIELDNAME'); foreach($genderoptions as $option) { $genderid = $option->id; $gendervalue = $option->$value; $gendertitle = $option->$title; if ($storedgender == $genderid) { $genderstatus = " selected"; } else { $genderstatus = ""; } $genderoptionstag .= "<option$genderstatus value='$genderid'>$gendertitle</option>"; }; //here you can output the option tags wherever you want (in my case in the user frontend form) echo $genderoptionstag;
  2. Hello at all, I have added a select field with the option field type where the user can select the gender (mister or miss) to the user template. On the frontend the user has a profile page with a form where he can update his user data (if he/she is logged in). On the frontend form I call the gender option field in this way: //grab stored gender from DB $storedgender = $user->usergender; //make select for gender options $genderoptions = $fieldtypes->get('FieldtypeOptions')->getOptions('usergender'); foreach($genderoptions as $option) { $genderid = $option->id; $gendervalue = $option->$value; $gendertitle = $option->$title; $genderselected = ""; if ($storedgender == $genderid) { $genderstatus = " selected"; } $genderoptions .= "<option$genderselected value='$option->id'>$option->title</option>"; }; //here you can output the option tags wherever you want (in my case in the user frontend form) echo $genderoptions; This renders the output in the way that I want but..... Problem: The comparison between the stored user gender (e.g. mister with the value 1) and the genderstatus "selected" doesnt work and I dont know why $genderselected = ""; if ($storedgender == $genderid) { $genderstatus = " selected"; } //this kind of comparison doesnt set the selected status correctly It always put the status "selected" to the first option in the foreach statement independent of the stored user gender. I cant figure out what the problem could be ? Has anyone an idea? I've been trying for some time to find a solution, but I can not find one. Best regards Jürgen
  3. Why dont you check the image with an if statement? if($page->img){ $header_image = $page->img->size(800,250)->URL; } Or am I misunderstand your question?
  4. Its done: https://processwire.com/talk/topic/2074-module-page-edit-field-permission/page-2
  5. Be careful: break site if using with 2.5.25 in my case. Take a look at https://processwire.com/talk/topic/9565-upgrade-from-2524-to-2525-broke-the-site/#entry92025
  6. Thats true but it worked quite well until this update. Anyway! My recommendation: Be careful if you use this module with wire version 2.5.25 - it brokes the site in my case
  7. After uninstalling the PageEditPermission module the upgrade works as expected. I made the update and after that I reinstall the module once more. The error appear once more. I dont need this module at the moment, but this module causes the error. So it seems that it is not compatible with the latest version at the moment
  8. Hello Horst, I have looked into that before I have posted this topic, but I couldnt find the reason on line 8 and 69. <?php /** * Provides the implementation for the PageEditFieldPermission::getModuleConfigInputfields method * */ function PageEditFieldPermissionConfig(array $data) { $inputfields = new InputfieldWrapper(); $f = wire('modules')->get('InputfieldMarkup'); $f->label = 'How to use this module'; $f->attr('name', '_instructions'); $config = wire('config'); $f->value = <<< _OUT <p> To use, create a <a href='{$config->urls->admin}access/permissions/'>new permission</a> and name it <b>page-edit-[field]</b>, replacing [field] with the name of the field you want to limit access to. <em>Better yet, use the tool below to create them for you and save some time.</em> </p> <p> Once your page-edit-[field] permission(s) exist, <a href='{$config->urls->admin}access/roles/'>add them to any roles</a> that you want to have edit access to the field. Roles that have edit access to a page, but do not have the required page-edit-[field] permission will not be able to see or modify the [field] in the page editor. </p> <p>Note that none of this applies to users with the superuser role, as they always have access to edit everything.</p> _OUT; $createPermissions = wire('input')->post->_create_permissions; if($createPermissions) foreach($createPermissions as $name) { $name = wire('sanitizer')->pageName($name); $permission = wire('permissions')->add("page-edit-$name"); $permission->title = "Access to edit the '$name' field"; $permission->save(); wire('modules')->message("Added permission: $permission->name"); } $inputfields->add($f); $f = wire('modules')->get('InputfieldCheckboxes'); $f->attr('name', '_create_permissions'); $f->label = 'Handy tool to create permissions for you'; $f->optionColumns = 3; $f->description = 'Check the box next to each field name you would like this tool to create a permission for you. This is the same thing as going to the Permissions page and creating them yourself, so this is here primarily as a time saver.'; $fields = array('name', 'parent', 'template', 'status'); $notes = ''; foreach(wire('fields') as $field) $fields[] = $field->name; foreach($fields as $name) { if($name == 'pass') continue; if(wire('permissions')->get("page-edit-$name")->id) { $notes .= "$name, "; continue; } $f->addOption($name); } if(!$notes) $notes = "[none yet]"; $f->notes = "Fields that already have permissions: " . rtrim($notes, ", ") . ". " . "Non-superuser roles that have page-edit access will no longer be able to see/edit these fields unless the appropriate permission is assigned to that role. "; $inputfields->add($f); return $inputfields; } Line 8 is function PageEditFieldPermissionConfig(array $data) { and line 69 is the closing bracket at the end
  9. I use the upgrade module - it was not updated via FTP. It seems that PageEditFieldPermission Module doesnt work with the latest version.
  10. After upgrade I got the following error: Compile Error: Cannot redeclare PageEditFieldPermissionConfig() (previously declared in /home/.sites/24/site1275/web/site/modules/PageEditFieldPermission/PageEditFieldPermissionConfig.php:8) (line 69 of /home/.sites/24/site1275/web/site/modules/PageEditFieldPermission/PageEditFieldPermissionConfig.php) This error message was shown because you are logged in as a Superuser. Error has been logged. I upgraded wire and index.php not the htaccess file. At the moment I changed it back to 2.5.24 to get it working. Does anyone struggle with the same problem?
  11. For all users with the same problem: Downloading inputfields.js and the minified version from Github solved the problem. I had slightly different js files in my directory and they have caused the strange behaviour. Thanks to all contributors for their efforts to solve the problem.
  12. If I change $config->debug = true to $config->debug = false in config.php the strange behaviour is back. If I change it back then it works. I will add it to the minified version too because it will be loaded if debug is off. Addition: I have downloaded the latest min-version from Github and now it works also with debug off. I have updated my PW to the latest version but I had another js version - very strange!!!! Now everything works fine.
  13. Yep I think so! ProcessWire Core (Development) ProcessWire dev 2.5.24 2.5.24 Auf dem neuesten Stand But your piece of code was not in my JS file.
  14. This code doesnt add anything to the log files (wheter checked or unchecked). This piece of code solves my problem. Now checkbox fields work as expected as dependency field! Thank you so much for your effort!!!!! From now on you are no longer LostKobrakai - you are BestKobrakai Best regards Jürgen
  15. With condition "0" and checkbox checked: <li style="display: block;" class="Inputfield InputfieldCheckbox Inputfield_facebookaktivation..... With condition "0" and checkbox unchecked: <li style="display: none;" class="Inputfield InputfieldCheckbox Inputfield_facebookaktivation.... Work as expected!! With condition "1" and checkbox checked: <li class="Inputfield InputfieldCheckbox Inputfield_facebookaktivation.... With condition "1" and checkbox unchecked: <li class="Inputfield InputfieldCheckbox Inputfield_facebookaktivation.... As you can see no CSS-inline-style will be added!!
  16. Here is the problem: Field snintegration - Current value: 1 inputfi...s?v=13c (Zeile 20) Field snintegration - Matched? YES inputfi...s?v=13c (Zeile 20) Field snintegration - Current value: 0 inputfi...s?v=13c (Zeile 20) Field snintegration - Matched? NO inputfi...s?v=13c (Zeile 20) ---- inputfi...s?v=13c (Zeile 20) Determined that field "facebookaktivation" should be visible. inputfi...s?v=13c (Zeile 20) Field is already visible. The field is always visible independent if the value matches or not!!!!!! This only happens if I choose the value "1" as condition - with the value "0" it works as expected.
  17. This is from the console: Checkbox is checked: JqueryC...s?v=183 (Zeile 2) ------------------------------------------------------------------- inputfi...s?v=13c (Zeile 20) Field "socialnetworksintro" detected a change to a dependency field! Beginning dependency checks... inputfi...s?v=13c (Zeile 20) ---- inputfi...s?v=13c (Zeile 20) Start Dependency 0 inputfi...s?v=13c (Zeile 20) Condition type: show inputfi...s?v=13c (Zeile 20) Field: socialnetworkactivation inputfi...s?v=13c (Zeile 20) Operator: = inputfi...s?v=13c (Zeile 20) Required value: 1 inputfi...s?v=13c (Zeile 20) Field socialnetworkactivation - Current value: 1 inputfi...s?v=13c (Zeile 20) Field socialnetworkactivation - Matched? YES inputfi...s?v=13c (Zeile 20) ---- inputfi...s?v=13c (Zeile 20) Determined that field "socialnetworksintro" should be visible. inputfi...s?v=13c (Zeile 20) Field is already visible. inputfi...s?v=13c (Zeile 20) ------------------------------------------------------------------- inputfi...s?v=13c (Zeile 20) Field "Inputfield_fieldset1" detected a change to a dependency field! Beginning dependency checks... inputfi...s?v=13c (Zeile 20) ---- inputfi...s?v=13c (Zeile 20) Start Dependency 0 inputfi...s?v=13c (Zeile 20) Condition type: show inputfi...s?v=13c (Zeile 20) Field: socialnetworkactivation inputfi...s?v=13c (Zeile 20) Operator: = inputfi...s?v=13c (Zeile 20) Required value: 0 inputfi...s?v=13c (Zeile 20) Field socialnetworkactivation - Current value: 1 inputfi...s?v=13c (Zeile 20) Field socialnetworkactivation - Matched? NO inputfi...s?v=13c (Zeile 20) ---- inputfi...s?v=13c (Zeile 20) Determined that field "Inputfield_fieldset1" should be hidden. inputfi...s?v=13c (Zeile 20) Field is now hidden. inputfi...s?v=13c (Zeile 20) 1 visibility changes were made. inputfi...s?v=13c (Zeile 20) InputfieldWindowResizeActions() Checkbox is not checked: JqueryC...s?v=183 (Zeile 2) ------------------------------------------------------------------- inputfi...s?v=13c (Zeile 20) Field "socialnetworksintro" detected a change to a dependency field! Beginning dependency checks... inputfi...s?v=13c (Zeile 20) ---- inputfi...s?v=13c (Zeile 20) Start Dependency 0 inputfi...s?v=13c (Zeile 20) Condition type: show inputfi...s?v=13c (Zeile 20) Field: socialnetworkactivation inputfi...s?v=13c (Zeile 20) Operator: = inputfi...s?v=13c (Zeile 20) Required value: 1 inputfi...s?v=13c (Zeile 20) Field socialnetworkactivation - Current value: 1 inputfi...s?v=13c (Zeile 20) Field socialnetworkactivation - Matched? YES inputfi...s?v=13c (Zeile 20) Field socialnetworkactivation - Current value: 0 inputfi...s?v=13c (Zeile 20) Field socialnetworkactivation - Matched? NO inputfi...s?v=13c (Zeile 20) ---- inputfi...s?v=13c (Zeile 20) Determined that field "socialnetworksintro" should be visible. inputfi...s?v=13c (Zeile 20) Field is already visible. inputfi...s?v=13c (Zeile 20) ------------------------------------------------------------------- inputfi...s?v=13c (Zeile 20) Field "Inputfield_fieldset1" detected a change to a dependency field! Beginning dependency checks... inputfi...s?v=13c (Zeile 20) ---- inputfi...s?v=13c (Zeile 20) Start Dependency 0 inputfi...s?v=13c (Zeile 20) Condition type: show inputfi...s?v=13c (Zeile 20) Field: socialnetworkactivation inputfi...s?v=13c (Zeile 20) Operator: = inputfi...s?v=13c (Zeile 20) Required value: 0 inputfi...s?v=13c (Zeile 20) Field socialnetworkactivation - Current value: 1 inputfi...s?v=13c (Zeile 20) Field socialnetworkactivation - Matched? NO inputfi...s?v=13c (Zeile 20) Field socialnetworkactivation - Current value: 0 inputfi...s?v=13c (Zeile 20) Field socialnetworkactivation - Matched? YES inputfi...s?v=13c (Zeile 20) ---- inputfi...s?v=13c (Zeile 20) Determined that field "Inputfield_fieldset1" should be visible. inputfi...s?v=13c (Zeile 20) Field is now visible. inputfi...s?v=13c (Zeile 20) 1 visibility changes were made.
  18. Markups: 1) Checkbox not checked: <input id="Inputfield_socialnetworkactivation" class="FieldtypeCheckbox" name="socialnetworkactivation" value="1" type="checkbox"> 2) Checkbox checked: <input id="Inputfield_socialnetworkactivation" class="FieldtypeCheckbox" name="socialnetworkactivation" value="1" checked="checked" type="checkbox"> As you can see in the source code the value is always 1, the difference is only checked="checked" In the log files no entry!
  19. Outputting the value in frontend shows 1 or 0 as expected. <?php echo $page->mycheckboxfieldname;?> The form is only an admin form to create content in the backend and there I am not able to change the values of the checkboxfield.
  20. Hello @ all, I use a checkbox field to show or hide other fields in my form in the backend. If the checkbox is checked then show the fields. If the checkbox is unchecked then hide the fields. Unfortunately it will only work if I add the following condition to a field which has the field dependency mycheckboxfieldname=0 but it doesnt work if I add mycheckboxfieldname=1 As far as I know the values of checkboxes are 0 and 1 (unchecked and checked) I have no idea why it doesnt work. This case also doesnt work mycheckboxfieldname!=0 I use the latest dev version and the input field dependencies with checkboxes have worked in the past, but now I have troubles. Has anyone an idea?
  21. Issue was fixed by Ryan. $options = $fieldtypes->get('FieldtypeOptions')->getOptions('YOURFIELDNAME'); foreach($options as $option) { echo $option->id; echo $option->value; echo $option->title; } This output all your options (id, value or title). This piece of code doesnt work multilingual. It only outputs the default language. If you have a multilingual site you have to output value and title in the specific language. //get value and title in different languages; if ($user->language->name != 'default') { $title = "title{$user->language}"; $value = "value{$user->language}"; } else { $title = 'title'; $value = 'value'; } $options = $fieldtypes->get('FieldtypeOptions')->getOptions('YOURFIELDNAME'); foreach($options as $option) { echo $option->id; echo $option->$value; echo $option->$title; }; Hope this is useful for others!
  22. hello @ all, I have upgraded to the latest dev version and have tried the new image upload function for the ckeditor. It works quite well but I cant find a button to remove an image from the page if it is not used anymore. Have I missed something or is this not possible? Thanx for your answeres
  23. Damn, Ryans solution doesnt work! $options = $fieldtypes->get('FieldtypeOptions')->getOptions('YOURFIELDNAME'); foreach($options as $option) { echo $option->title; } OR $field = $fields->get('YOURFIELDNAME'); $options = $field->type->getOptions($field); It produces also the error
  24. Maybe this could be a solution posted by Ryan: https://processwire.com/talk/topic/9018-new-options-fieldtype/ I havent tested it, because I am not at home. If it works I write a feedback here. Best regards Jürgen
  25. I found the sequence but I dont understand how to output it at the frontend! /** * Get all options available for the given field * * @param id|string|Field $field Field name, id or object * @return SelectableOptionArray * @throws WireException * */ public function getOptions($field) { return $this->manager->getOptions($field = $this->_getField($field)); } Maybe in a way like this?? $options= $fields->get("fieldname")->????;
×
×
  • Create New...