Jump to content

Zeka

Members
  • Posts

    1,049
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zeka

  1. As @Ivan Gretsky said, the core of CKEditor 5 has changed and implementing it in PW will require significant changes, so maybe we should consider other options like https://imperavi.com/article. It is also used in Bolt CMS (not a promotion).
  2. Hi @digitalhandwerker In your scenario, where you are getting pages by their paths would be more appropriate to use $page->getByPath() method like $pages->getByPath('/en/', [ 'useLanguages' => true, ]);
  3. Hi @fruid You have to turn on advanced mode by setting this in your config.php $config->advanced = true; Than on settings tab on that page you will be able to toggle 'system' checkbox
  4. Hi @JerryDi I would recommend getting to know with 'owner' selector as it could be beneficial in the setups Ryan provided. https://processwire.com/blog/posts/processwire-3.0.95-core-updates/
  5. As an option https://processwire.com/blog/posts/pw-3.0.173/#telling-processwire-what-page-to-render
  6. https://github.com/processwire/processwire/blob/master/wire/config.php#L516
  7. There is also an option to use cookie and htaccess RewriteEngine On RewriteCond %{HTTP_COOKIE} language=(ua|en) [NC] RewriteCond %{REQUEST_URI} !^/(ua|en)/ [NC] RewriteRule ^(.*)$ /%1/$1 [R=301,L]
  8. Hi @Matzn <?php namespace ProcessWire; class ParentModule extends WireData implements Module, ConfigurableModule { public static function getModuleInfo() { return [ 'title' => 'Parent Module', 'version' => 1, ]; } const defaultValue = '12345'; public function __construct() { $this->set('api_user', self::defaultValue); // set default value in construct } public function getApiUser() { return $this->api_user; } public static function getModuleConfigInputfields(array $data) { if(!isset($data['api_user'])) $data['api_user'] = self::defaultValue; $form = new InputfieldWrapper(); $f = wire('modules')->get('InputfieldText'); $f->name = 'api_user'; $f->label = 'API USER'; $f->value = $data['api_user']; $form->add($f); return $form; } } <?php namespace ProcessWire; class ChildModule extends ParentModule { public static function getModuleInfo() { return [ 'title' => 'ChildModule', 'version' => 1 ]; } public function __construct() { parent::__construct(); bd($this->getApiUser()); bd($this->wire()->modules->getModuleConfigData('ParentModule')); } } Take a look at the construct method of ChildModule. Without calling parent::__construct you will not be able to get what you want. Also you can use $this->wire()->modules->getModuleConfigData('ParentModule') to get config data of module.
  9. Hi @prestoav Try to output this https://processwire.com/api/ref/session/get-all/
  10. Not sure, but probably getFresh method is applicable in such a case. https://processwire.com/api/ref/pages/get-fresh/
  11. https://processwire.com/docs/modules/hooks/#how-can-i-add-a-new-method-via-a-hook
  12. Hi @theoretic You are adding a property via hook instead of method https://processwire.com/api/ref/wire/add-hook-method/
  13. There is no built-in functionality. The simplest way is to create addtional fields like 'page_views' and 'page_popularity', then populate these fields inthe desirerable way and use them in your selectors like pages('template=post, sort=-page_views');
  14. Why just not create a text field like 'externa_id' and then check it while import like foreach ($import_records as $import_record) { $exists = $this->wire()->pages->has("template=some-template, external_id=" . $import_record['unique_id']); if($exists) { // update } else { // create a new page } }
  15. Hi @swissdoode . Take a look at Inputfields.js file, there are many methods that you could find helpfull https://github.com/processwire/processwire/blob/dev/wire/templates-admin/scripts/inputfields.js#L37
  16. Hi @toni. Process modules is intended to be used in admin and they are not autoloaded, so for such hook you can create an satelite autoload module or put this code to init.php file. class URLHooker extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'URLHooker', 'version' => '0.1', 'singular' => true, 'autoload' => true, 'requires' => [ 'YourProcessModule>=0.1' ], ); } public function init() { $this->wire()->addHook('/hello/world', function($event) { return 'Hello World'; }); } }
  17. Also take a look at ProcessHello module https://processwire.com/modules/process-hello/ https://processwire.com/blog/posts/pw-3.0.181-hello/ https://github.com/ryancramerdesign/ProcessHello
  18. https://github.com/processwire/processwire/blob/dev/wire/core/ProcessController.php#L388
  19. Hi @erikvanberkum It should return current langauge values without any additions to the code, so make sure that you made translations in field configuration.
  20. Hi. Is there a way to find pages by $page->meta data? Thanks.
  21. Hi @torf Have you tried to hook InputfieldPageAutocomple::findPagesSelector?
  22. @netcarver Have you tried using boot.php? In site/config.php $config->statusFiles = array( 'boot' => 'boot.php', 'init' => 'init.php', 'ready' => 'ready.php', 'finished' => 'finished.php' ); and in boot.php <?php namespace ProcessWire; wire('classLoader')->addNamespace('Wireframe\Blocks', paths('templates') . 'blocks/'); wire('classLoader')->addNamespace('Wireframe\Traits', paths('templates') . 'traits/'); I don't remember if I used traits in pages classes or in some other parts of the code, but you can try.
  23. @gregory Not sure that I got it. Do yo meen to output translated values? If so, AFAIC it should work without any aditions to the code and will output values for current user language, but if you want to output values in the specific langauge you can change user langauge before gettting options and then change it back to current langauge. $field = $fields->get('tipologia'); $currentLanguage = wire()->user->language; wire()->user->language = wire()->languages->get('another langauge name'); $all_options = $field->type->getOptions($field); wire()->user->language = $currentLanguage; $selected_option = $all_options->get("title="); // or ? foreach($all_options as $item) { $selected = $item->id === $selected_option->id ? " selected='selected' " : ''; echo "<option$selected value='{$item->id}'>{$item->title}</option>"; }
  24. Hi @gregory Something like this $field = $fields->get('tipologia'); $all_options = $field->type->getOptions($field); $selected_option = $all_options->get("title=" $input->item); // or id=some_id foreach($all_options as $item) { $selected = $item->id === $selected_option->id ? " selected='selected' " : ''; echo "<option$selected value='{$item->id}'>{$item->title}</option>"; }
×
×
  • Create New...