Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/20/2021 in all areas

  1. https://processwire.com/api/ref/page/set-and-save/ // Not needed: $order->of(false); $order->setAndSave([ 'pad_user' => $u->id, 'expire_date' => $expireDate, ]);
    5 points
  2. @bernhard - I completely agree that there is no point using AOS for just this purpose. That was my intention by saying "if you are already running" in my comment above. I know it's unmaintained, but with the features I use from it, I haven't noticed any bugs - I am sure there are likely some features that are buggy. The problem is that I really struggle to use PW without it. Just an FYI - when it was first being developed, I thought it was a crazy idea - way too hard to maintain and make stable with all those features, but it works for my needs, but I completely agree it's not something that should be recommended for one simple feature like this.
    3 points
  3. Hi Marc, I quit my job as developer. I really wanted to work in the outside air and with my hands again. I'm building garden sheds these days and I love it. Maybe someone wil take over some modules I made in the past.
    3 points
  4. @fedeb Looks like I missed a spot on the updates to the Event class, I have fixed that and removed the references to the old fields (location, notes). 1. In ProcessWire a Page can be in a "output formatted" or unformatted state. You can toggle output formatting on with $page->of(true); or toggle it off with $page->of(false); Or you can get the current state with $formatted = $page->of(); When output formatting is on, values returned from the page are intended for output and thus can contain runtime formatting such as entity encoding. This is good for output, but definitely not something you'd want saved the database, so when you are creating pages or saving values on pages you want to have its output formatting disabled, i.e. $page->of(false); This should be done before getting, setting or modifying values that will be saved. 2. The location and notes aren't supposed to be there. I removed them in favor of making the module simpler by just having "title" and "date", and then people can add any additional columns they want. 3. The set() and get() functions are inherited from the WireData class. (Event extends WireData) 4. InputfieldEvents won't be included unless something asks for it (like the page editor in the admin). If you are just using the API side, then the InputfieldEvents module likely will never be loaded or come into play. It's still nice to have in case you ever want to see or edit your data in the admin.
    2 points
  5. @adrian I'd ask you to rethink recommending AOS for such simple tasks as adding scripts to the admin. I know you are a big fan of it, but the only reason I see for using AOS or ACF is if you don't know how to place a hook to your system. But if you are able to do that, it is a lot better to copy a 4line hook than adding another dependency to your site. The hook will likely work without any problems for several years... AOS is already unmaintained and has introduced problems to several of my sites that where quite hard to find... It would be even better of course to put that hook into a dedicated simple module that does everything that the injected script is for ?
    2 points
  6. Why not just add the file via hook? https://processwire.com/talk/topic/20725-add-possibility-to-prepend-or-append-scripts-and-stylesheets-in-admin/?do=findComment&comment=211800 $wire->addHookBefore('AdminTheme::getExtraMarkup', function (HookEvent $event) { $config = $this->wire->config; $url = $config->urls("MyModule"); $config->scripts->add($url."tabulator/js/tabulator.min.js"); $config->styles->add($url."tabulator/css/tabulator.min.css"); });
    2 points
  7. This seems to work (N.B. this is with a php array not a PageArray) $pages = $this->wire()->pages->find($selector); $pages = $pages->getArray(); // want them as a php array not an object if (strpos($selector, 'sort=path')) { usort($pages,function ($a, $b) { return ($a->path >= $b->path) ? 1 : -1; }); }
    1 point
  8. The $page->created is empty at that very moment you query it because it hasn't been set yet. <?php namespace ProcessWire; $timestamp = time(); $page->setOutputFormatting(false); $page->created = $timestamp; // that quiet=true part is important in this case $page->save(array('quiet' => true)); You could add the date on your own if the date is necessary for whatever reason in that moment.
    1 point
  9. Hi Martijn, That's great to hear! Sorry for bringing up this old module, but thanks for the reply. I'll see if i can dig into the code and make it work...
    1 point
  10. @kixe Thank you for this module! It saved me countless hours(probably days) of pain.
    1 point
  11. v0.0.53 It always annoys me not to have the correct page name replacements for german umlauts...
    1 point
  12. Hi everyone I´m creating an AdminTheme based on Semantic UI framework. Here is the beta version. I 'm fixing bugs. Github here Changelog: 0.0.1 --- Fixed background color / image.
    1 point
  13. This is a small tutorial... If you want add another field to this fieldtype... first in FieldtypeEvents.module in getDatabaseSchema() add a line that suit your needs, so your new field gets stored to the database $schema['newValue'] = 'TINYTEXT NOT NULL'; try if you can install the module and add a field to a template and check if it works like before add the property to the constructor in Events.php $this->set('newValue', ""); then modify set() and get() so you can modify your new property... now try in your template,´if you can modify and output the new property foreach($page->events as $event){ $event->newValue = "hello new value"; echo "yes it works, we we welcome the new value: ". $event->newValue."<br>"; } if this works properly then go back to FieldtyeEvents.module: add this line in __wakeupValue() to the foreach loop $event->newValue = $v['newValue']; and in _sleepValue() 'newValue' => $event->newValue, in file InputfieldEvents.module in renderRow() method make sure, a $newValue variable gets gets sanitized from $newValue = $this->sanitizer->entities($event->newValue); change $out = " <tr class='Event$cnt $class'> <td><a href='#' class='EventClone'><span class='ui-icon ui-icon-copy'></span></a></td> <td><input type='text' name='{$name}_date[]' value='$date' class='datepicker' /></td> <td><input type='text' name='{$name}_newValue[]' value='$_newValue' /></td> //add this line add your field in __render() <table class='InputfieldEvents'> <thead> <tr class=''> <th class='EventClone'>&nbsp;</th> <th class='EventDate'>Date</th> <th class='EventDate'>newValue</th> //I´ve chosen EventDate class because its narrow and in __processInput() $event->newValue = $input->{"{$name}_newValue"}[$cnt]; I hope I didn´t forget anything, good luck!
    1 point
  14. Kind of pointing out the obvious here, but that could be asking for trouble. A number of modules (including core ones, such as Repeaters) perform cleanup etc. with hooks. Unless you're really careful, you could easily leave a ton of orphaned data behind with this method.
    1 point
  15. I have a site that I oftentimes sync the live database to my dev database (I made a bash script to automate the process). I generally like to "clean" the database once it has been copied over to my dev machine, which involves running a script that deletes 15,000 pages (orders in my case), among other things. Doing this using $page->delete() in a script (which I'm running through the command line for added performance), takes about 30 minutes which is painful. I thought it through further and I came up with the following relatively simple script that can achieve the same result in a few seconds! It achieves this speed by running MySQL delete queries directly, bypassing PW's API. Here it is (modify accordingly): <?php namespace ProcessWire; ?> <?php include(dirname(__FILE__).'/index.php'); // bootstrap pw $order_ids = $pages->findIDs('parent=/orders/,template=order'); if(!count($order_ids)) exit; $order_ids = implode(",", $order_ids); $t = $templates->get("order"); foreach($t->fields as $f) { if( $f->type!="FieldtypeFieldsetOpen" && $f->type!="FieldtypeFieldsetClose" ) { $table = "field_".$f->name; $database->query("DELETE FROM $table WHERE pages_id IN ($order_ids)"); } } $database->query("DELETE FROM pages WHERE id IN ($order_ids)");
    1 point
×
×
  • Create New...