Jump to content

kixe

Members
  • Posts

    803
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by kixe

  1. @theo You can use html, but you'll need to create a new admin theme to accomplish this ... If the AdminTheme you are using extends the AdminThemeFramework class (UI-kit) or contains the AdminThemeDefaultHelper class, all tags are entity-encoded. https://github.com/processwire/processwire/blob/e73ec872da5f9db2960524dbb984287bfe4b7b4e/wire/core/AdminThemeFramework.php#L156
  2. $mostRecentlyCreatedPageByUser = $pages->get("created_users_id=$user->id,sort=-created");
  3. Of course ... /** * modify headline in page edit interface */ $wire->addHookAfter('ProcessPageEdit::headline', function($e) { // get id of page beeing edited $pid = (int) $this->input->get('id'); if (!$pid) return; $pageBeeingEdited = $this->wire('pages')->get($pid); if (!$pageBeeingEdited->id) return; $headline = "My ID is $pageBeeingEdited->id"; $this->wire('processHeadline', $headline); // no need to modify the return value ($e->return) });
  4. ... unlimited possibilities with a hook ... Code // ready.php $wire->addHookAfter('ProcessPageListRender::getPageLabel', function($e) { $listedPage = $e->arguments[0]; // ... $e->return = '...'; });
  5. @ngrmm Your solution looks good, since the mod operator is the fastest way to determine even/ odd in PHP, but I would loop only once. $even = ''; $odd = ''; foreach ($allPages as $k => $v) { if ($k % 2) { $even .= "<div>$v->title</div>"; } else { $odd .= "<div>$v->title</div>"; } } echo "<div class='items'>"; echo "<div class='odd'>"; echo $odd; echo "</div>"; echo "<div class='even'>"; echo $even; echo "</div>"; echo "</div>";
  6. To furthermore change or sort the columns to be displayed in the list, you can do that here: Modules > Configure > ProcessUser
  7. Enable tags in your image field Set predefined tag "homepage". Get urls of marked images $pages = wire('pages')->find('myImageField.tags=homepage'); foreach ($pages as $page) { echo $page->myImageField->get('tags=homepage')->url; }
  8. @noelboss ProcessDatabaseBackups (by Ryan) uses the same default format as CronjobDatabaseBackup (e.g. dbname-1.sql) whereas the core class WireDatabaseBackup uses the default format: dbname_YYYY-MM-DD_HH-ii-ss.sql I don' t know where this format is in use. Since CronjobDatabaseBackup is built very close to ProcessDatabaseBackups I will stay compliant and don't want to change the current default format for the filename. Anyway you have always the option to modify the format for your needs in module settings, even in the format you prefer.
  9. Put the code I have posted in your ready.php and replace $this with $wire. $wire->addHookBefore('PagefilesManager::path', function ($e) { $e->replace = true; $e->return = null; });
  10. Please post your code or explain exactly what you are doing.
  11. This is an old issue. I use the following workaround. In case of an unsaved page instance (id = 0) a hook is called from the render() method of my custom module, which provides a form (withfile field) based on a PW template in the frontend: $this->addHookBefore('PagefilesManager::path', function ($e) { $e->replace = true; $e->return = null; }); https://github.com/ryancramerdesign/ProcessWire/issues/1259
  12. You need to enable 'modal' in module JqueryUI Don't set the href attribute. In this case the button will be wrapped by an anchor tag and you will be redirected to the url which you want to open in the modal. Use 'data-href' instead. If you set the property 'aclass' a class attribute value will be added to the anchor wrapper not to the button itself. Use function addClass() instead. Try this: wire('modules')->get('JqueryUI')->use('modal'); $btnAddNew = wire('modules')->get("InputfieldButton"); $btnAddNew->attr('data-href', wire('config')->urls->admin."page/add/?parent_id=1101&modal=1"); $btnAddNew->attr('id', "MyCustomAddPageButton"); // required for the additional button on top $btnAddNew->showInHeader(); $btnAddNew->addClass("pw-modal");
  13. @titanium Sorry for the extremely delayed answer. Thanks for pointing on this. I pushed an update which allows to use InputfieldColor as a config field for modules. I have made some changes in the code you have posted and tested it within the following module. Everything seems to work. Please check out. <?php namespace ProcessWire; class My2Module extends WireData implements Module, ConfigurableModule { /** * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'My2Module', 'summary' => 'Module with Config Input of type Color', 'version' => 100 ); } static public function getDefaultConfig() { return array( 'color' => '#ff3300' ); } public function __construct() { foreach(self::getDefaultConfig() as $key => $value) { $this->$key = $value; } } /** * Initialize, attach hooks * */ public function init() { // ... } /** * module settings * */ static public function getModuleConfigInputfields(array $data) { $fields = new InputfieldWrapper(); $defaults = self::getDefaultConfig(); $data = array_merge($defaults, $data); $colors = [ 'name' => 'color', 'inputType' => 3, 'type' => 'color', // will search for 'InputfieldColor' // 'outputFormat' => 3, // REMOVED outputFormat is related to the Fieldtype and not to the Inputfield // 'defaultValue' => '#ff0080ff', // REMOVED @see getDefaultConfig() and __construct() // 'alpha' => 0, // REMOVED related to 'inputType=4', otherwise automatically set by the Inputfield 'spectrum' => "showInput: true\nallowEmpty:true\nshowAlpha: true\nshowInitial: true\nchooseText: \"Alright\"\ncancelText: \"No way\"\npreferredFormat: \"hex3\"", // 'class' => 'FieldtypeColor', // REMOVED (unnecessary) 'label' => __('Label'), 'description' => __('Description'), 'required' => false, 'value' => $data['color'], 'notes' => __('Initial value: '.$defaults['color']), ]; $fields->add($colors); return $fields; } }
  14. $pages->find() return a PageArray. Using echo PageArrays always return a string of the Page IDs separated by pipe "|" characters. Since you are looking for a single page you may want to use $pages->get(). To get the title of the page use $pages->get()->title. $pages$tags = explode(',', $page->tags); foreach ($tags as $tag) { $tag = trim($tag); echo $pages->get("tags=$tag")->title; }
  15. ... and don't forget to read this
  16. ProcessWire is even more, it has capabilities to be a conventional CMS with highly configurable Administration Interfaces, Templatesystem, Database Mangement/ Access and render tools for the output of dynamic markup headless CMS providing content data via API (JSON, GraphQL) and optionally static HTML + JavaScript (HUGO/ Jekyll) WAF (Web Application Framework) a platform to build a headless CMS or other App/ SaaS on top of fit Make your choice!
  17. The task is to change a runtime property (visibility) of a field and setting/saving a page field value if certain conditions are met. Hooks are great but not needed to solve this task.
  18. /** * check & hide specific checkbox field if page being edited has no children */ if ($page->process == 'ProcessPageEdit' && $input->id) { $field = $fields->get('createevents'); $_page = $pages->get($input->id); if ($_page->template->fields->hasField('createevents')) { if ($page->hasChildren() == false) { $field->set('flags',160); $field->setRoles('edit',array()); // works for non superuser only $_page->setAndSave('createevents', true); } } }
  19. @kongondo $this inside any template file will return the TemplateFile object and inside ready.php the ProcessWire object. @Juergen If you need to disable fields for certain roles or make them view only take this as a starting point. Put the code in your ready.php foreach ($fields as $field) { if ($field->hasFlag(8) && $field->name !== 'title') continue; // skip system fields `Field::flagSystem` $field->addFlag(160); // Add flags `Field::flagAccess` = 32 + `Field::flagAccessEditor` = 128 // Applicable only if the `Field::flagAccess` is set to this field's flags. $field->editRoles = array(); // leave empty if you want to give access to superuser only $field->viewRoles = array(1026); // assign field view permission to specific roles (IDs) // save the field $field->save(); }
  20. Does the customer have view permission for template: shop-order? If not, try to add check_access=0 to your selector string. // Get the orders $orders = wire('pages')->find("template=shop-order, order_user_id=$customer, sort=-datetime, limit=10, check_access=0, include=all");
  21. @Karl_T I fixed this too but without publishing here. Sorry for this Furthermore I added options for the label etc. In the environments I use it (latest PW) everything works as expected, even single select. I forked now the original module and pushed my latest version on github. https://github.com/kixe/Processwire_FieldType_Templates
  22. Small CSS Border (left) issue using UIKit AdminTheme
  23. If $widget is a page object it should be possible to put outputformatting on just to grab the value and switch it of after. If not you can use the formatValue() function from the module. You need a page and a field object as arguments. $page can be any page in this case but $field should be the one where the OF type is stored. $FieldtypeColor = wire('modules')->get('FieldtypeColor'); $field = new Field(); $unformattedColor = "ff5a01fd"; $page = new Page(); $field->type = $FieldtypeColor; $field->outputFormat = 0; $color = $FieldtypeColor->formatValue($page,$field,$unformattedColor); var_dump($color); // string(7) "#5a01fd"
  24. @Macrura Page output formatting? $page->of(false); var_dump($page->color); // string(8) "ff5a01fd" $page->of(true); var_dump($page->color); // string(7) "#5a01fd"
×
×
  • Create New...