-
Posts
807 -
Joined
-
Last visited
-
Days Won
10
Everything posted by kixe
-
User - display field values from their most recent created page
kixe replied to Peter Knight's topic in API & Templates
Quick check debug mode on? any warnings, notices, errors? does $mostRecentlyCreatedPageByUser->id return something > 0? is $mostRecentlyCreatedPageByUser->city and $mostRecentlyCreatedPageByUser->miles populated? You should check the latter 2 in your template before echo. -
User - display field values from their most recent created page
kixe replied to Peter Knight's topic in API & Templates
@Peter Knight Good that it works. It is always best practice to choose the selector in a way that the mysql query is as accurate as possible and thus fast. I'm still surprised that the original selector returns nothing. -
@adrian Got this error after install and trying to edit a page. Error: Uncaught Error: Call to a member function getLanguageValue() on null in .../site/modules/BatchChildEditor/BatchChildEditor.module:860 The error occurs due to the fact there is no title field assigned to the page template. I think your module should handle this since its easy to remove title now with the $template->noGlobal option. .. and this one in the exported csv file after using the template you provided in the README.md <br /> <b>Notice</b>: Undefined index: configurablePages in <b>.../site/assets/cache/FileCompiler/site/modules/BatchChildEditor/ProcessChildrenCsvExport.module</b> on line <b>94</b><br /> <br /> <b>Warning</b>: in_array() expects parameter 2 to be array, null given in <b>.../site/assets/cache/FileCompiler/site/modules/BatchChildEditor/ProcessChildrenCsvExport.module</b> on line <b>94</b><br /> <br />
-
User - display field values from their most recent created page
kixe replied to Peter Knight's topic in API & Templates
@Peter Knight Yes, you have to add 'sort = -created' otherwise you will get 'sort=id' by default. In contrast to find(), get() returns only a single page (the first page from the PageArray to which your selector applies). If you get nothing, the user has not yet created a page or the user is the guest user (not loggedin), or the page have the status hidden or unpublished. You can add selectors like include=hidden|unpublished|all. -
@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
-
User - display field values from their most recent created page
kixe replied to Peter Knight's topic in API & Templates
$mostRecentlyCreatedPageByUser = $pages->get("created_users_id=$user->id,sort=-created"); -
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) });
-
... unlimited possibilities with a hook ... Code // ready.php $wire->addHookAfter('ProcessPageListRender::getPageLabel', function($e) { $listedPage = $e->arguments[0]; // ... $e->return = '...'; });
-
@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>";
-
To furthermore change or sort the columns to be displayed in the list, you can do that here: Modules > Configure > ProcessUser
-
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; }
-
@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.
-
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; });
-
Please post your code or explain exactly what you are doing.
-
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
-
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");
-
@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; } }
-
$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; }
-
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!
-
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.
-
/** * 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); } } }
-
@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(); }
-
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");
-
@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