Leaderboard
Popular Content
Showing content with the highest reputation on 04/18/2016 in all areas
-
proud to share the release of a little handy sorting module for image and file fields (edit: some bugs in the screencast that are already solved) the autosort option can be set in the field-admin: Caution there is some work planned on the images field, so this may break the functionality of this module. have this in mind. github: https://github.com/BernhardBaumrock/InputfieldFileSort module directory: http://modules.processwire.com/modules/inputfield-file-sort/ changelog 1.0.0 initial release7 points
-
ClearCacheAdmin Module Since there's so many asking how to clear cache. Here comes a helper module that let's you clear caches directly from the admin menu. Additionally it has its own admin page that's a collection of the various caches available in ProcessWire in one place. See some infos and clear them. WireCache (using $cache) caches in the DB and there no way to clear it from the admin. Now you can delete the entries individually or all in one go. Supports following cache types: - Template "Page" Cache (disk file cache) - MarkupCache module (file cache) - WireCache (DB) - Other files and directories found in assets/cache/ path Wanted to do this for a long time. It was also great fun to do it and give something to the community to also learn something. For now it's on github only. Requires ProcessWire 2.6+. https://github.com/somatonic/ClearCacheAdmin5 points
-
Now that's some hookception $pages->addHookAfter("ProcessPageEdit::buildFormContent", function($event) { $wrapper = $event->return; if(!$wrapper->has('singleeventtable')) return; if (count($wrapper->singleeventtable->attr("value")) == 0) { $this->error('Achtung! Sie haben noch keine Termine erstellt'); $wrapper->singleeventtable->collapsed = Inputfield::collapsedHidden; } });4 points
-
New update to v0.0.5. Lowered minimum required PW version. I just tested it on a install with PW 2.6.10 and fixed some small issues. Added support for WireCache entries using a selector as expires instead of a date.3 points
-
3 points
-
The simplest answer is that classnames cannot be shortened, but namespaces can. The ProcessWire namespace is not the best example here, because it's still not to long, therefore I'll use some namespaces from the flysystem package. use Aws\S3\S3Client; use League\Flysystem\AwsS3v3\AwsS3Adapter; use League\Flysystem\Filesystem; $client = S3Client::factory($credentials); $adapter = new AwsS3Adapter($client, 'your-bucket-name', 'optional-prefix'); $filesystem = new Filesystem($adapter); […] if(!$filesystem instanceof Filesystem) die(); // vs. $client = Aws\S3\S3Client::factory($credentials); $adapter = new League\Flysystem\AwsS3v3\AwsS3Adapter($client, 'your-bucket-name', 'optional-prefix'); $filesystem = new League\Flysystem\Filesystem($adapter); […] if(!$filesystem instanceof League\Flysystem\Filesystem) die(); Now imagine you'd need to use these classes 15 times in a file. You'd have to write them 15 times in their full glory without namespaces. With them you can always use the shortname of a class in your code, which keeps it readable and even if the shortname would collide you can do this to use an alternative short name for one of those in the file. (Alternativ naming does even work if classes don't clash.) <?php namespace kobrakai; use ProcessWire\User as PwUser; class User extends PwUser {} The use statement is super useful because you hardly need conflicting classes in a single file. Therefore you declare once which class you want to use in a file and never care about it later on. With longer classnames you need to constantly care about it trying to remember that one special long class name. The next benefit is the "folder" structure namespaces give yourself. As long as classes are in the same namespace you don't actually need to do anything besides the namespace declaration once. Only accessing classes outside the current namespace does need you to specify the namespace in any way. > kobrakai > Form > ImageGallery > … <?php namespace kobrakai; use DateTime; use ProcessWire\PageArray; class Form { public function ImageGalleryButtons(PageArray $options) { // Namespace needed $g = new ImageGallery(); // No namespace needed […] $date = new DateTime(); // DateTime is a core class, therefore also another namespace (root) } } Like you've seen above namespaces are great to extend classes. If I want to change a already existing file, which does use ProcessWire\User to use my own implementations (with maybe some additional business logic) I just change the use statement and I'm done. The file is still as readable as before. There were 100% no accidents in trying to search/replace classnames. We are still talking about users. <?php use kobrakai\User; // from: use ProcessWire\User; $u = new User; $u->name = 'my-user'; … if($another_u instance of User) $u->friend->add($another_u); …3 points
-
This module is deprecated in favor of RockMigrations. It'll continue to work and I might fix some smaller incompatibilities if they're reported, but no major development will happen on this anymore. There where various threads about a how to reasonably handle multiple dev/staging and live environments with ProcessWire and at best handle it as automatically as possible. A git based workflow makes it easy to handle files, but the pain point of migrating db changes has even lead to multiple requests of not handling template/field storage in the db at all. I've gone ahead and used for my own projects the concept of database migrations, which most frameworks are using to handle database changes – but the ProcessWire flavored way. ___ ___ ___ ___ ___ ___ ___ /\__\ /\ \ /\ \ /\ \ /\ \ /\ \ /\ \ /::L_L_ _\:\ \ /::\ \ /::\ \ /::\ \ \:\ \ /::\ \ /:/L:\__\ /\/::\__\ /:/\:\__\ /::\:\__\ /::\:\__\ /::\__\ /::\:\__\ \/_/:/ / \::/\/__/ \:\:\/__/ \;:::/ / \/\::/ / /:/\/__/ \:\:\/ / /:/ / \:\__\ \::/ / |:\/__/ /:/ / \/__/ \:\/ / \/__/ \/__/ \/__/ \|__| \/__/ \/__/ Beta This module does help you managing migration files, where any database changes can be stored in php files using just the simple ProcessWire api at your disposal. It's not as nice as using the admin UI, but certainly better than trying to migrate changes manually and possibly weeks after adding the changes. Also there's always the option to create helper modules, which can export changes made in the admin UI to something usable in those migration files. For example I'm using an internal process module, which does let me export changes to template access rules as json strings, which I then use in my migrations to actually apply the changes. Now on to the meat – How to use the module: Read the following guide on creating own migrations Maybe use the CLI tool to speed up your workflow (and possibly automate stuff) It is generally recommended, but not enforced, that migrations are run/rolled back in order. When doing migrations or rollbacks, without specifying a migration, this module will stick to the order. Creating Migrations Your migrations will probably hold lot's of code, which does delete data. By now this module does not have any security measurements to prevent that. Be sure to test your migrations locally and possibly keep a database backup before running them. There are currently four types of migrations: default (Migration) Default migrations are the most free form migrations. There's just a description and two functions – update() and downgrade(). What you're doing in those functions is totally up to you, but it's recommended to try the best to keep changes as reversible as possible. Meaning that running update() and downgrade() once should have as less effect on the installation as possible. The ProcessWire API is available exactly like in modules using the $this->pages, $this->config, … syntax. FieldMigration TemplateMigration ModuleMigration All of those are there to make your life easier. They all have different but similar functions – which you can find in migrations created by this module – which ease the creation and removal of fields, templates or modules. All the boilerplate is handled by the base classes these migrations do extend, so you don't even need to think about update() and downgrade(). You can rather just describe the item you want to handle and the creation / removal process is taken care of. These are by now not highly tested, so please again be sure to test migrations before running them on important content. Command-Line Interface The module does include a cli interface, which does allow the migrations to be run automatically by CI or deployment scripts or just by you if you like cli's. The cli script is located in the bin directory inside the module's folder. It does however require a composer package to work, which you can simply add by running composer require league/climate in your site directory (or the root directory for pw 3.0). Make sure to require composers autoload.php in your config.php for 2.x installations. The CLI does have a quite handy help page, which you get by running php migrate -h so I'm just adding the important bits of that here: > php migrate -h […] Usage: migrate [-h, --help] [-i info, --info info] [-m migrate, --migrate migrate] [-n new, --new new] [-nf newField, --newField newField] [-nm newModule, --newModule newModule] [-nt newTemplate, --newTemplate newTemplate] [-r rollback, --rollback rollback] Optional Arguments: -m migrate, --migrate migrate Run a specific migration or all new* ones if none given. * From latest migrated to newest. -r rollback, --rollback rollback Undo a specific migration or the latest one if none given. -n new, --new new Bootstrap a new migrations file. Optionally you can already supply a description. -nt newTemplate, --newTemplate newTemplate Bootstrap a new template migrations file. Optionally you can already supply a description. -nm newModule, --newModule newModule Bootstrap a new module migrations file. Optionally you can already supply a description. -nf newField, --newField newField Bootstrap a new field migrations file. Optionally you can already supply a description. -i info, --info info Get detailed info about a migration. -h, --help Show all commands of the cli tool. Link the migrations cli update save to ProcessWire's root: https://processwire.com/talk/topic/13045-migrations/?p=118329 Helper Functions There are already a handful of helper function included in the Migration base class, which tackle things I found to need way to much boilerplate for kinda simple changes, but you can also add own custom helper functions via hooks. /** * This does use @diogo's while loop technique to loop over all pages * without getting memory exhaustion. */ $this->eachPageUncache("template=toBeHidden", function($p){ $p->setAndSave('status', Page::statusHidden); }); /** * $template, $field, $reference = null, $after = true * The below function reads like this: * In the template … add the field … relative to the field … in the position after/before */ $this->insertIntoTemplate('basic-page', 'images', 'body', false); /** * Edit field settings in context of a template */ $this->editInTemplateContext('basic-page', 'title', function($f, $template){ $f->label = 'Headline'; }); And a simple example of adding a custom helper as a hook. // in ready.php $wire->addHook('Migration::renameHome', function(HookEvent $event){ $name = $event->arguments(0); wire('pages')->get('/')->setAndSave('title', $name); }); // in the migration $this->renameHome('Root'); Snippets Still not sure how all this works in practice? Or you want to share a maybe more complex migration? Just head over to the Snippets Repo at Github. https://github.com/LostKobrakai/MigrationSnippets There are also less specific examples in the modules repository: https://github.com/LostKobrakai/Migrations/tree/master/migrations Appendix As long as the module is in Beta the helper functions in the Migration.php might be object to change/removal, so be aware of that. Download http://mods.pw/Bm https://github.com/LostKobrakai/Migrations2 points
-
This works!!! Here is the complete code for others who are interested in: //initialize the function in the module public function init(){ $this->addHookAfter("ProcessPageEdit::buildFormContent", $this, "renderpagetable"); } public function rendepagetable($event){ $wrapper = $event->return; $page = $event->object->getPage(); if(!$wrapper->has('singleeventtable')) return; $itemnumber = count($page->children); if ($itemnumber == 0) { $this->message('There are no items in the page table field'); $wrapper->singleeventtable->collapsed = Inputfield::collapsedHidden; } else { $this->message("Number of items:{$itemnumber}"); } } } "singleeventtable" is the name of my page table field - replace it with your own page table field name. Special thanks to netcarver and LostKobraKai for helping to find a working solution.2 points
-
Otherwise try: $event->object->getPage()->singleeventtable->count()2 points
-
Have you tried hooking ProcessPageEdit::buildFormContent? Like this; $pages->addHookAfter("ProcessPageEdit::buildFormContent", function($event) { $wrapper = $event->return; $wrapper->YOUR_FIELD->collapsed = Inputfield::collapsedHidden; }); If that works, you can add conditional logic to only apply it as needed. I usually apply this kind of hook in site/ready.php.2 points
-
What if you disable the config module and just use the /site/config.php? Have you entered the domains in both? Also, you might want to check if ProcessWire (or PHP) is able to get the proper hostname. I had one case (on a shady server, long time ago) where PHP didn't recieve the proper hostname so ProcessWire kept telling me that I needed to update the hostname.2 points
-
hi robin, as simple as this: (put it in your /site/ready.php file and adjust to your needs) $this->pages->addHookAfter('added', function($event) { $page = $event->arguments[0]; if($page->template != 'your-template-name') return; $page->setAndSave('title', 'my page - ' . date("YmdHis")); }); set page name format for children to something like Y/m/d H:i:s and set title to locked2 points
-
I've just commited a few smaller updates (most on Jonathan's requests) Migration descriptions are now escaped, so that characters like double quotes or backslashes won't break any newly created migrations. Also the backend UI does now feature a textarea instead of a text input to allow for multiline description entry. In the cli one would have to add "\n" linebreaks manually. The module does now try to add the /site/migrations/ path automatically, when it's called for the first time (e.g. by accessing the admin UI page) I've added a basic onboarding page for the admin UI, when there are no migrations, which does now feature a "Create New" button to get started. Jonathan did also request the addition of importer migrations for modules like FormBuilder or HannaCode. I'm not really keen on adding those and especially maintaining them. I'd rather suggest creating a GitHub repo, where the community can add migration snippets via pull-request. For example using the FormBuilder importer is just a single line of code, whereas the HannaCode importer would need to be copied nearly completely, because it's so tightly coupled with it's backend form. This repo option would be an easy way to just share the bits of boilerplate which is sometimes needed to do things via the api. Additionally I'm going to add some example above on how to add own helper methods to the Migration class with hooks, so everybody can add his own helper functions. Edit: I've added the mentioned docs about helper functions.2 points
-
Finally, I got spared some time to work on a project I have been meaning to do for a while. This follows on from this request and other discussions about the pros/cons of an ApiGen for ProcessWire. I am all for such docs as long as two conditions are met: (i) That it is clearly indicated who the target audience is; and (ii) that the docs are regularly updated. I think this project meets both. I have created a GitHub project and project pages for hosting regularly auto-updated PHP ApiGen Docs for ProcessWire 3 (master and dev) as well as ProcessWire 2.8 (master). We also have ProcessWire 2.7 (master and dev) docs but these are not updated since this version of ProcessWire is no longer active. The whole doc-generation process is automated including auto-pushing changes to GitHub. The current cycle is: ProcessWire 2.8.x Master branch docs: updated once at the beginning of every month ProcessWire 3.x Master branch: updated once at the beginning of every month ProcessWire 3.x Dev branch: updated once weekly, every Friday Docs are generated for all .php and .module files under /wire/core/ and /wire/modules/. Currently, this is all done via my home PC. I am on a Windows machine so nothing could really go wrong... . Barring the unforeseen, these docs should be roughly in step with the latest ProcessWire commits. Now running on a remote server. Tools used Windows PowerShell (move over wget! ) wget Git-Bash Windows Task Scheduler (there's your cron right there ) cron Pear APIGEN Scripts: PowerShell, Bash Script, VBS and Batch files A couple of stress balls I hacked together a dark theme for this project, sublime-text default look. The CSS still needs some work, all help appreciated, thanks. If anyone would like to create an alternative theme, we could incorporate a theme switcher. Feeback, thoughts, suggestions (e.g. text in READMe, etc)? Credits to Ryan for writing such well-commented code...otherwise this project would not have been possible. From the READMe1 point
-
Because it is maybe interesting for others I will answer a question I got in the personal messenger: Does the module have the capability to run from a standard cron job? Yes. The Backup is triggered by the hook function cronBackup() expecting a HookEvent as single argument, which is in fact not needed. If you want to trigger the backup from anywhere, just create a HookEvent object and call the cronBackup() function. Done. $event = new HookEvent; $modules->get('CronjobDatabaseBackup')->cronBackup($event);1 point
-
@kongondo, @horst, @BitPoet, Thank you for welcoming me. OK, I tried soma installer and it work quite nicely, except everything is the name of the apache user www-data, meaning I have to change the owner of the site/ directory and if I want to tinker with ProcessWire, I'll have to do that for the whole installation I got ProcessWire 2.7.2 instead of 3.0.15 I do want the 3.0.x branch, and I want to stay up to date with the branch. This why I used git. I'm ready to live with some bugs. This is mostly a learning project though some of it may go out later when the 3.0 branch goes beta or stable. @horst, this is why, at first, I would copy site-default to site and chmod 777 access config.php and modules before starting installation. But on @BitPoet suggestion, I didn't do any of that before starting another installation. I did correct everything after these errors showed up. Checking in install.php, I see in initProfile.php that it does try to rename the profile I chose. But since I clone the repository, the files belong to me, not to the apache user. So the installer is unable to create the site. It will work with grabpw.php because it is the installer that creates the files. So they belong to the apache user. Anyway, I finally manage to install my project with 3.0.15. Now, the fun part starts Yet, I would like to know why this error occurred. Maybe later, when I am familiar with the code, I'll hunt it down. ProcessWire looks like an awesome framework, doing things in a completely different way compare to other frameworks and challenging the brain a bit. For example, I started designing my project, making the database schema and stopped right there realizing that PW is mostly about pages, templates and fields. No need for a full database design. Anyway, I want to thank you all for taking the time to answer me. This looks like a very, very friendly community.1 point
-
What kixe said, but to add to this: It's not as simple as adding a button attribute or some different url processwire would provide. This would need you to have a url (or page, can be the page the button is on), which serves as wrapper for the image file. You then use the url of this page as the source for the download. You probably need some kind of trigger for the download, to differenciate it from normal requests, which is done either via a urlSegments or a GET variable in the url. In the template you can then check for the trigger / filename and run wireSendFile on the file the user does try to download.1 point
-
I've created a little module for that: https://processwire.com/talk/topic/13064-inputfieldfile-image-sorting-autosorting/1 point
-
/** * Send the contents of the given filename via http * * This function utilizes the $content->fileContentTypes to match file extension * to content type headers and force-download state. * * This function throws a WireException if the file can't be sent for some reason. * * @param string $filename Filename to send * @param array $options Options that you may pass in, see $_options in function for details. * @param array $headers Headers that are sent, see $_headers in function for details. * To remove a header completely, make its value NULL and it won't be sent. * @throws WireException * */ function wireSendFile($filename, array $options = array(), array $headers = array()) { $http = new WireHttp(); $http->sendFile($filename, $options, $headers); } Usage $file = $page->filefield->first()->filename(); // or $page->filefield->filename(); depending on your settings wireSendFile($file, array('forceDownload' => true, 'exit' => true)); Example Allow url segments in the template where your button and image exists. $img = $input->urlSegment1? (int) $input->urlSegment1:0; $download = $input->urlSegment2 == 'download'?true:false; $file = $page->filefield->eq($img); if ($download) { wireSendFile($file->filename(), array('forceDownload' => true, 'exit' => true)); } else { echo "<img alt='' src='{$file->url}'/>"; echo "<button><a href='$number/download/'>Download Picture</a></button>"; }1 point
-
$tasks = $pages->find("task_person*=$user->name,parent=/tasks/,include=hidden,sort=-created");1 point
-
$names = "ali,sradesign,nona"; $names = strtr($names, ',','|'); $users = $users->find("name=".$names); @LostKobrakai Always quick1 point
-
$names = explode(',', $names); $names = array_map('trim', $names); $names = implode('|', $names); $users->find("name=$names");1 point
-
So this was it! Seriously, this is needed. Or at least mentioned in the $input docs.1 point
-
1 point
-
If there are only 60 pages i find it strange that it would take more than 6 seconds to get a couple of random pages. It's also funny that your limit 100 is larger than the actual number of pages, but it is twelve times faster (500ms versus 6 seconds) when you put the limit the selector. I'm not sure what is going on here. Apart from that, as LostKobrakai said, when getting random pages from a large number of pages the sort=random is preferable. However, when you would get into a really big number of pages even that would probably become slow. (i've done some simple tests in the past: https://processwire.com/talk/topic/8626-multiple-random-ads/?p=83345 )1 point
-
For those who would rather like the cli tool to live in another directory (e.g. root in my case) you can use this in a file named 'migrate': <?php // Full or relative path to the module's cli include_once __DIR__ . '/site/modules/Migrations/bin/migrate';1 point
-
1 point
-
Hook before InputfieldPageTable::render and set the "collapse" mode to hidden if the table is empty and it's your specified field.1 point
-
I just tested and it is doing exactly what you imagined and I need. Thanks again! EDIT: forgot to mention that it also is much faster1 point
-
Just lost my text due to wrong shortcut -.- (maybe auto storing in local storage would be nice ) but anyways.. Now I got you maba. Thanks to you I just notices that my pages weren't working too.. I actually don't really now what fixed the issue and maybe just re-installing could fix it but there is a new Version with some changes you could grab during re-installation process..see changelog in readme for detail Make sure to remember your settings before uninstalling! Please let me know if everything works now. Sorry Manfred for the late response and thank you for the translation! I just stripped the \n for now But it won't be included on your front pages templates so it works only in backend. You can of course reference the version used by PW but you have to do it yourself (or am I missing something?) Moved "Default true" to end of former line.. I have no idea why \n is not working I always used it as it's suggested in the docs and as far as I remember it always worked?! EDIT: 0.1.2 adds minified CSS & JS1 point
-
hhm, yes, but may be also: no.!? - At least, then you will need the php user to have filesystem write access, or not?1 point
-
Probably best to point out (to new users) that setAndSave() is a recent addition. Otherwise you might bet questions why is it not working for me?1 point
-
sorry adrian for being late - there was too much going on in this thread so i set notifications to weekly... the simplest solution would be to send a get request like this: some errors: https://validator.nu/?doc=https://processwire.com/talk/&out=json valid: https://validator.nu/?doc=https://processwire.com/&out=json maybe parse this json and set the color of the panel to green = valid, orange = warnings, red = errors and a link to the validator report. nothing more needed, i think1 point
-
In my case, it's only been worth the effort for one site that I deal with that is doing constant imports all day. It makes a difference in the performance of other requests there. There are a lot of technical benefits to InnoDB relative to MyISAM for sure. But in the PW context (or most CMS contexts) it's hard to derive much value from those benefits until you run into specific needs or scale. In 15+ years and thousands of MyISAM tables around here, I've never experienced any kind of data corruption or loss associated with MyISAM tables. If starting something new I think InnoDB is worthwhile if it can be supported in your environment, but for most cases of existing PW installations I don't think it's worth the effort unless the circumstances mentioned in post are present. From what I understand, MyISAM's fulltext indexes may still be stronger than InnoDB's, though not positive that's still the case. Btw, PW will use InnoDB either way for cases where it makes the most difference.1 point
-
I like InnoDB, it has row-level locking and is ACID compliant - so I'm biased. That said, I'm not really making a call one way or the other (I know nothing about your application) I was just trying to provide the only performance data I have.1 point
-
Love the new panel thingy! Especially the 'side effect' that you can use it as some sort mediaquery tester while dragging the pane .1 point
-
You can alter an existing table simply by issuing ALTER TABLE your-table-name ENGINE=InnoDB; Though you may want to keep the original MyISAM table around. Here's a small bootstrap script to drop into the templates folder that converts all tables, either inplace (if $keepOld near the top is set to false) or creating a copy and keeping the MyISAM tables around postfixed with "_orig". It also writes a timestamped SQL file into the templates folder that allows you to switch back to MyISAM. Small caveat: if you select to keep your old tables, those will replace the generated InnoDB tables on restore, which means that all PW changes in between are lost - this may or may not be desired. So to use it, simply drop it in the templates folder of the PW installation in question and run it from the command line. It will check if you MySQL version is recent enough. <?php /** * Convert all tables in PW's database from MyISAM to InnoDB */ include('../../index.php'); // Set this to false if you do not want to keep your MyISAM tables around // with an _orig postfix $keepOld = true; // ***************************************************************************** $sql = "select substring(version(), 1, 1) as vmajor, substring(version(), 3, 1) as vminor "; $stmt = $database->query($sql); if($stmt === false) die("Something went wrong determining the version number!"); $row = $stmt->fetch(PDO::FETCH_ASSOC); $versionOK = false; if($row['vmajor'] > 5 || ($row['vmajor'] == 5 && $row['vminor'] >= 6)) $versionOK = true; if(!$versionOK) { die("You need MySQL 5.6 or later for InnoDB fulltext support!"); } // Version check finished, get list of tables $stmt = $database->prepare( "SELECT table_name" . " FROM information_schema.tables" . " WHERE table_schema = '" . $config->dbName . "'" . " AND lower(engine) != 'innodb'" ); $count = 0; if($stmt->execute()) { $tbls = $stmt->fetchAll(PDO::FETCH_ASSOC); echo "Found " . count($tbls) . " tables not running on InnoDB" . PHP_EOL; if(count($tbls) == 0) { echo "Nothing to do!" . PHP_EOL; exit; } $ts = strftime("%Y%m%d_%H%M%S"); $restore = fopen("restore_to_myisam_{$ts}.sql", "w+"); echo "- writing restore commands to file restore_to_myisam_{$ts}.sql" . PHP_EOL; // Convert each table foreach($tbls as $tbl) { $tabname = $tbl['table_name']; echo $tabname . PHP_EOL; if($keepOld) { // Create a copy of each table, convert the new table, // copy the content and switch table names $sql = "CREATE TABLE {$tabname}_convert LIKE $tabname"; if($database->exec($sql) === false) continue; echo "... Created copy of " . $tabname . PHP_EOL; $sql = "ALTER TABLE {$tabname}_convert ENGINE=InnoDB"; if($database->exec($sql) === false) continue; echo "... Changed engine to InnoDB" . PHP_EOL; $sql = "INSERT INTO {$tabname}_convert SELECT * FROM $tabname"; if($database->exec($sql) === false) continue; echo "... Copied content to InnoDB table" . PHP_EOL; $sql = "RENAME TABLE $tabname TO {$tabname}_orig," . " {$tabname}_convert TO $tabname"; if($database->exec($sql) === false) continue; echo "... Switched tables" . PHP_EOL; fputs($restore, "RENAME TABLE $tabname TO {$tabname}_innodb," . " {$tabname}_orig TO $tabname;" . PHP_EOL); fputs($restore, "DROP TABLE {$tabname}_innodb;" . PHP_EOL); $count++; } else { // Convert tables in place $sql = "ALTER TABLE $tabname ENGINE=InnoDB"; if($database->exec($sql) === false) continue; echo "... " . $tabname . " converted" . PHP_EOL; fputs($restore, "ALTER TABLE $tabname ENGINE=MyISAM;" . PHP_EOL); $count++; } } fclose($restore); } echo "Converted $count tables from MyISAM to InnoDB" . PHP_EOL; Edit: incorporated @LostKobrakai's suggestion to avoid nesting if statements.1 point
-
Hi, welcome to the forums. I'm not sure what you have done with "git checkout -b devns" and afterwards with "git checkout -b dev", but dev and devns are two seaparate branches of Processwire. dev is the 2.7.3+ dev branch, and devns is the 3.0.15+ branch. I'm not comfortable with git, but why do you checkout two times?1 point
-
And 3.x in fact - I've got it running on an installation there with no issues (auto-compiling for namespaces nicely).1 point
-
Thanks for the report. I commited an update that fixes this. I hadn't thought about it and was runnning php 71 point
-
Not at all. Yeah why not. But I originally just wanted to be able to trigger the various caches by simply using their own API. I wasn't doing any real operations or deletions just delegation. I now added support for "Other files and directories in the site/assets/cache/ dir". For now they will now show up in menu and on admin page and you can delete them recursively. Version 0.0.2 is commited.1 point
-
Lovely looking site. First thing I saw was Bradley Wiggins. One of his gold post boxes is a couple of hundred metres from our office. Small world.1 point
-
Ok, so it seems really like the repeater does just not pick up it's pages for whatever reason. For the record, which pw version are you using?1 point
-
Hi @justb3a, thank you very much for your fast reply. The submitName is now working. I forgot to explicitly set a templateName on both instances, because I assumed it would fallback to the default if nothing is declared. If I set templateName and submitName on both it works. Thanks for the description of the submit-behavior. I am currently highlighting the required fields if the user moves forward without filling them out, what seems as a legit workaround. With one form I am running into – [FAILURE] Number of fields does not match. – even though the same hidden fields are available as on the other form. The form itself has one more field than the other one, but I set them with the allFields-key. Do you have a hint for me what I might have overlooked? Thanks, Depone Edit 2016-04-14: fixed – error was caused by a field-name mismatch.1 point
-
I've made a first translation file for german: GitHub All strings are translatable, but line 98 ist not working: 'notes' => sprintf(__("For example Font Awesome checkmark icon e.g. %s\n(You need to include Font Awesome on your own)"), "<i class='fa fa-check'></i>"), with single quotes it works, but without the newline \n. Maybe don't use the \n? Or delete part of string "(You need to include Font Awesome on your own)", because Font Awesome is already included in PW. same problem with line 217: 'notes' => __("Default true\nIt has been suggested that this setting can effectively help to reduce identity theft through XSS attacks"),1 point
-
Hi everybody, I'd like to share with you another new module. It helps you to manage user ratings for pages in a very simple way. You can add a user rating to a certain page with a line of code: $page->ratings->add(4) If the user is logged in, the module remembers which page the user has rated for. For non-logged-in visitors, the module stores the pages, the user has rated, in the session. You can get a page's rating and its total amount of votes in a similar way: $page->ratings->average; // => 3.2 $page->ratings->count; // => 5 For more information about this module, please check out its GitHub repository. You can check out a working version of the module here: http://curium-cte.lightningpw.com Edit: The module is now available in the ProcessWire modules directory. Update: Ratings has been updated to version 1.1, including a new, simpler API accessor. As always - please comment for bugs or feature wishes. Thanks in advance, Marvin1 point
-
Sorry little late at the party but like i wrote a little how to use MSN for a megamenu or add any other items between items... this should be the result - some li item with extra div content with latest/top article and some other items in this example from a pagefield/categories.... Code ist hopefully well commented... //topMenuNav $rootPage = $page->get('/'); //shows current tree $topMenu = $modules->get("MarkupSimpleNavigation"); // load the module // hook to have custom items markup $topMenu->addHookAfter('getTagsString', null, 'customNavItems'); function customNavItems(HookEvent $event){ $item = $event->arguments('page'); // get the article mainnav item and add some megamenu items... if($item->id == 1068){ //build the normal li item output $out = '<a href="'.$item->get("url").'">'.$item->get("title|name").'</a>'; //get the last article $top_article = wire('pages')->find("template=artikel,top_thema=1,sort=-publish_from")->first(); //get the last article $latest_article = wire('pages')->find("template=artikel,sort=-publish_from")->first(); //get image thumb from $top_article //get the original image $imagetop = $top_article->get("artikel_bild"); // get the image instance of the cropped version of "artikel" 750px wide $thumbtop = $top_article->artikel_bild->getCrop('Artikel'); //get image thumb from $latest_article //get the original image $imagelatest = $latest_article->get("artikel_bild"); // get the image instance of the cropped version of "artikel" 750px wide $thumblatest = $latest_article->artikel_bild->getCrop('Artikel'); //get the items for the tagmenu $cat_items = wire('pages')->find("template=artikel_cat"); //get the rootpage of the posts $artikel_root = wire('pages')->get(1068); //homepageurl $homepageurl = wire('pages')->get('/')->httpUrl; //start megamenu $out .= '<ul class="mega">'; //first column last "top" marked article $out .= '<div class="one_third"><h4 class="subtitle">Top Aktuell</h4>'; $out .= '<a class="mega-link-img" href="'.$top_article->get("url").'"><img src="'.$thumbtop->url.'" alt="'.$thumbtop->description.'"><br></a>'; $out .= '<h6><strong>'.$top_article->get("headline").'</strong></h6>'; $out .= '<p>'.$top_article->get("shorttext").'</p>'; $out .= '</div>'; //second column - latest article $out .= '<div class="one_third"><h4 class="subtitle">Letzter Artikel</h4>'; $out .= '<a class="mega-link-img" href="'.$latest_article->get("url").'"><img src="'.$thumblatest->url.'" alt="'.$thumblatest->description.'"><br></a>'; $out .= '<h6><strong>'.$latest_article->get("headline").'</strong></h6>'; $out .= '<p>'.$latest_article->get("shorttext").'</p>'; $out .= '</div>'; //third column - list of tags (links to URL segments on artikel_stamm template) $out .= '<div class="one_third"><h4 class="subtitle">Themenbereiche</h4>'; foreach ($cat_items as $cat) { $out .= '<li><a href="'.$homepageurl.$artikel_root->name.'/'.$cat->name.'/">'.$cat->title.'</a></li>'; } $out .= '</div>'; //close megamenu $out .= '</ul>'; $event->return = $out; } } $options = array( 'parent_class' => 'parent', // overwrite class name for current parent levels 'current_class' => 'current', // overwrite current class 'has_children_class' => 'has_children', // overwrite class name for entries with children 'levels' => true, // wether to output "level-1, level-2, ..." as css class in links 'levels_prefix' => '', // prefix string that will be used for level class 'max_levels' => 3, // set the max level rendered 'firstlast' => false, // puts last,first class to link items 'collapsed' => false, // if you want to auto-collapse the tree you set this to true 'show_root' => false, // set this to true if you want to rootPage to get prepended to the menu 'selector' => 'template!=artikel|event', // define custom PW selector, you may sanitize values from user input 'selector_field' => 'nav_selector', // string (default 'nav_selector') define custom PW selector by using a property or field on a page. Use this setting if you want to overwrite the default nav_selector 'outer_tpl' => '<ul id="nav" class="sixteen columns">||</ul>', // template string for the outer most wrapper. || will contain entries 'inner_tpl' => '<ul>||</ul>', // template string for inner wrappers. || will contain entries //'list_tpl' => '', // template string for the items. || will contain entries, %s will replaced with class="..." string 'list_field_class' => '', // string (default '') add custom classes to each list_tpl using tags like {field} i.e. {template} p_{id} 'item_tpl' => '<a href="{url}">{title}</a>', // template string for the inner items. Use {anyfield} and {url}, i.e. {headline|title}, if field is of type image it will return url to image (first image if multiple) 'item_current_tpl' => '<a href="{url}">{title}</a>', // template string for the active inner items. 'xtemplates' => '', // specify one or more templates separated with a pipe | to use the xitem_tpl and xitem_current_tpl markup 'xitem_tpl' => '', // same as 'item_tpl' but for xtemplates pages, can be used to define placholders 'xitem_current_tpl' => '', // same as 'item_current_tpl' but for xtemplates pages 'date_format' => 'Y/m/d', // default date formatting for Datetime fields and native created/modified 'code_formatting' => true, // enable or disable code indentations and newslines in markup output 'debug' => false, // show some inline information about rendertime and selectors used as html comments ); $topMenuMarkup = $topMenu->render($options, null, $rootPage); It's long and detailed i always like to see how all options of the Menu are set....so options could be less. Hope this works for others as example how to get there with MarkupSimpleNavigation...on such topics. I like this module very much since in my former CMS there was a great function for generating menus, too. With this kind of generating markup for navigation it is not always easy but it is always very powerfull and if you've it running it a solid solution Best regards mr-fan1 point