-
Posts
741 -
Joined
-
Last visited
-
Days Won
12
Posts posted by psy
-
-
Hi @Margie
I'm an Aussie ProcessWire developer. Happy to help you promote the ProcessWire cause

-
3
-
-
On 14/08/2017 at 0:43 AM, benbyf said:
I've been thinking for ages to whether it was possible to view the contents of a folder from dropbox on your site and create public links to files - use case: upload your resources to this folder in dropbox and they'll automatically appear on the site?
Tested and confirmed you can do this. Simple example (no paging although that's possible too):
<?php namespace ProcessWire; use Kunnu\Dropbox\Dropbox; use Kunnu\Dropbox\DropboxApp; use Kunnu\Dropbox\DropboxFile; $drop = $modules->get('DropboxAPI'); //Configure Dropbox Application $app = new DropboxApp($drop->app_key, $drop->app_secret, $drop->authorization_code); //Configure Dropbox service $dropbox = new Dropbox($app); $listFolderContents = $dropbox->listFolder(""); //root folder is the folder you nominated in the Dropbox App config. Refer doco $items = $listFolderContents->getItems(); ?> <ul> <?php foreach ($items as $item) : ?> <li><?=$item->getName()?></li> <?php endforeach; ?> </ul>
As for download links, you could use the Dropbox Chooser https://www.dropbox.com/developers/chooser#javascript or create your own with javascript.
-
2
-
-
Thanks Ben
- The token request could be on the admin side BUT the Dropbox call back URL must be a publicly viewable page to receive the token. I chose to put both the request and response on the same page and then unpublish the page once I'd received the token.
- According to the documentation, https://github.com/kunalvarma05/dropbox-php-sdk/wiki/Working-with-files the answer is yes. The PW module really does little more than authenticate the user and allow you to create the $dropbox object (as in example above for sending a file). Add all the appropriate "use" namespace statements in your template and you'll have full access to the API, including the ability to List Folder Contents
-
3
-
Tip:
By default the Dropbox App is in Development mode and allows only one user - you. When you apply for a token you may get a Dropbox notification saying you need more users. Simply go back into your Dropbox App configuration and click on the button to the right of this setting. You'll automatically be granted 500 development users.
Should you need more than 500 users, you'll need to apply to Dropbox for Production status for your App and totally outside the scope of this ProcessWire Dropbox API module.
-
3
-
-
Quote3 minutes ago, teppo said:
At this point my best suggestions would be DropboxAPI, just plain Dropbox, or perhaps DropboxUpload... though that last one only if you are sure that you'll never add anything other than upload support for it

Changed it to DropboxAPI

-
2
-
-
Thanks for the tip. Was a bit confused about naming conventions. The module doesn't render anything so not Markup, and to me, it was a 'process', although granted, not a PW process.
Done. Let me know if there are any problems relating to the name change.
-
3
-
-
ProcessWire DropboxAPI on GitHub: https://github.com/clipmagic/DropboxAPI
This module is a wrapper for Kunal Varma's Dropbox PHP SDK https://github.com/kunalvarma05/dropbox-php-sdk
It was created to perform a specific function for a client, ie upload PDF files on a PW website to a specific Dropbox account folder.
The PDF files, created using @Wanze's excellent PagesToPdf module using the WirePDF functions, are generated from Formbuilder forms completed by front-end site visitors. Works a treat!
There's more that could be done to allow ProcessWire to take advantage of all the features of the SDK, eg downloads, multiple Dropbox accounts, etc. You are welcome to request changes and/or fork the GitHub project to extend the feature set.
Enjoy!
System requirements
- PHP 5.6.4 or greater
- Composer
- The PHP mbstring extension
General information
This module enables you to access a single Dropbox (www.dropbox.com) account to upload files from a ProcessWire website.
All kudos to (https://github.com/kunalvarma05/dropbox-php-sdk) for the PHP API.
First steps
- Visit (https://www.dropbox.com/developers) and read the documentation.
- Log into Dropbox and create a new application. It's recommended to limit ProcessWire App access to a specified folder
- Make a note of the App key, the App secret and the name of the Dropbox folder
Installation
- Download the zip file into your site/modules folder then expand the zip file.
- Next, login to ProcessWire > go to Modules > click "Refresh". You should see a note that a new module was found. Install the DropboxAPI module.
- Configure the module with your App key, App secret and your Call Back URL
You need to generate a Dropbox access token to enable your site to communicate with the nominated Dropbox account. Dropbox will generate a token for you or you can create a page for the front end of your ProcessWire site with a template to submit the token request to Dropbox, eg:
<?php namespace ProcessWire; $drop = $modules->get('DropboxAPI'); if ($input->get->code && $input->get->state) { $code = $sanitizer->text($input->get->code); $state = $sanitizer->text($input->get->state); //Fetch the AccessToken $accessToken = $drop->getAccessToken($code, $state); echo "Copy/paste this code into the module configuration: " . $accessToken; } else { echo "<p><a href='" . $drop->getAuthURL() . "'>Log in with Dropbox</a></p>"; } ?>Once you have entered the token in the module configuration, you can unpublish this page.
Usage
Read the dropbox-php-sdk documentation!
An example template for sending a file to a Dropbox App folder from ProcessWire:
<?php namespace ProcessWire; use Kunnu\Dropbox\Dropbox; use Kunnu\Dropbox\DropboxApp; use Kunnu\Dropbox\DropboxFile; // send pdf to Dropbox $drop = $modules->get('DropboxAPI'); $app = new DropboxApp($drop->app_key, $drop->app_secret, $drop->authorization_code); if ($app) { //Configure Dropbox service $dropbox = new Dropbox($app); $dropboxFile = new DropboxFile('/path/to/myfilename.pdf'); $file = $dropbox->upload($dropboxFile, "/myfilename.pdf", ['autorename' => true]); //Uploaded File meta data if ($file) { $success = $file->getName() . " uploaded to Dropbox"; $drop->log($success); } }-
13
-
Hi @maxf5
Thanks for the feedback. Wow, what results. Definitely not getting those slow speeds here. Will work on reducing the images sizes.

-
Feeling the love for ProcessWire today.
Two sites launched and owners over the moon happy.
Two additional sites ordered by existing clients and both specified ProcessWire as the platform.
New sites:
1. https://flywithmehorses.com.au/
Owner is just starting out in business and had already spent $100's dollars and 6+ months on a 'free' website without success. She helped me so I sponsored development of her site.
Client's comment: "OMGOSH this is sooo exciting!!!!!!! YAY!! Thank you alot!!!!! Can't wait to tell everyone!!! THANK YOU!!!"
ProcessWire 3.0.63
2. https://cttcfilmcourse.com/
Original site built in WordPress. Over 1000 lines of code on the home page and the https://validator.w3.org/ bombed out at line 124 with "Too many errors". Google's page speed insights were cringingly bad. Project was to keep the visuals and rebuild the site in PW with a solid foundation. Job done. No validation errors and vastly improved page speed insights. Also added search and better site navigation.
Client's comment: "So good!"
ProcessWire 3.0.63
Looking forward to working on the next two sites, both of which will be website apps with workflows rather than informational sites.As ever, grateful for comments/feedback to improve either site.
-
18
-
-
Quick workaround... in _main.php add
<region id="dummy"></region>
in basic-page.php add
<region id="dummy"></region>
Seems PW needs a region in the page template to kick-start the process.
-
3
-
-
I am using regions with the tag <region id="whatever"> in the _main.php file. Config file is set up as follows:
$config->useMarkupRegions = true; $config->prependTemplateFile = '_init.php'; $config->appendTemplateFile = '_main.php';
When I use a page template that changes a region, all goes well. However, I set up the _main.php file to reflect the output for a basic page. The basic-page.php template needed no customisation so was simply as follows:
<?php namespace ProcessWire; ?>
When a page with the basic-page template was output, all the <region> tags remained in the HTML, ie were not stripped.
When I added a customised region to the basic-page.php template, all the <region> tags were stripped from the output _main.php HTML.
Did I do something wrong or is this a bug?
Using ProcessWire 3.0.63 © 2017
-
Quote37 minutes ago, Vayu Robins said:
Thank you very much! You wouldn't have the link to that forum posting where Ryan helped on this?
There are many. I trawled the FB forum on the assumption my requirement wasn't unique

Here's one:
-
This works for me. User name is generated by PW from first name and last name fields. New user enters email, password and a couple of custom fields.
The user must be saved before the roles are added.
Hook developed with help, esp from Ryan, in the FormBuilder forum.
// Create new user from FormBuilder feu-register form $forms->addHookAfter('InputfieldForm::processInput', null, 'hookCreateUser'); function hookCreateUser(HookEvent $event) { $form = $event->object; if($form->name != 'my-fb-form-name') return; // if it's not the form you want, return // format the first_name and last_name as the username $sanitizer = wire('sanitizer'); $users = wire('users'); // ensure email address is valid and unique $email = $form->get('email'); $emailValue = $sanitizer->selectorValue($email->value); if($emailValue) { // check there aren't any other users with the same email $insiders = $users->find("include=all, email=$emailValue"); if($insiders->count > 0) { $email->error(__("Sorry that email is already in use")); return false; } } // makes sure the username is not already in use. $first_name = $sanitizer->pageName($form->get('first_name')->value); $last_name = $sanitizer->pageName($form->get('last_name')->value); if ($first_name && $last_name ) { $username = $first_name . '_' . $last_name; $u = $users->find("include=all, name^=$username"); if ($u->count > 0) { $number = $u->count+1; $username = $username . $number; } } else { // invalid or blank $username->error(__("Please enter a valid username")); } // ok, all checked, create user account $newUser = $users->add($username); $newUser->of(false); $newUser->email = $emailValue; $newUser->pass = $form->get('password')->value; $newUser->first_name = $form->get('first_name')->value; $newUser->last_name = $form->get('last_name')->value; $newUser->country = $sanitizer->text($form->get('country')->value); $newUser->phone = $sanitizer->text($form->get('phone')->value); $newUser->save(); $newUser->addRole('guest'); $newUser->addRole('my-custom-user-role'); // change to your user role name $newUser->save(); $newUser->of(true); }
-
1
-
-
On 11/05/2017 at 5:14 AM, Macrura said:
looks like the gallery detail pages are missing title tag, for example: https://rockpoolpainting.com.au/gallery/cooranbong/
@Macrura Thanks, sorry for the late reply, just saw your comment. Forgot to add album template to MarkupSEO allowed template list. Fixed
-
Solved!!! Answer was in the .htaccess file.
Remove reference to robots.txt being a physical file on the system.
#RewriteCond %{REQUEST_FILENAME} !(favicon\.ico|robots\.txt) RewriteCond %{REQUEST_FILENAME} !(favicon\.ico)-
2
-
1
-
-
Quote
But as soon as I name the page robots.txt I get the following error:
"The requested file robots.txt was not found."
Same for me
Thought maybe it was a $config setting but couldn't find anything.
Suggestions?
-
@OllieMackJames
Glad you like it

There are way too many schemas for me to include in the basic module. I chose what I thought would be the most useful. However you have a couple of options:
1. Use the custom schema option, eg:
$jsonld = $modules->get("MarkupJsonLDSchema"); $options = array(); $options["@type"] = "VideoObject"; $options["custom"] = array ( "actor" => "Barney Rubble", "caption" => "What an actor!", ... ); ?> <script type="application/ld+json"> <?php $jsonld->render('Custom',$options); ?> </script>
OR
2. Write your own schema and add it to the site/modules/MarkupJsonLDSchema/schemas/ directory. See the other schemas in there and their naming conventions as examples, and feel free to include your video schema code in this topic to share with others.
BTW, the link http://jsonld.com/video/ leads to a 404 Error. A much better resource is http://schema.org/VideoObject.Hope this helps
psy
-
1
-
-
Strangely, the odd order of the pw-append method was definitely repeatable for me. Even with the scripts in the correct order I was still having issues with js errors.
The <region> tag works ONLY if I have ProCache turned on to combine & minify scripts. Guessing the same would apply to All-In-One-Minify or similar modules. At least in my case, inline scripts execute too quickly unless the preceding scripts are forced to be loaded beforehand.
Lesson learned and all good

-
21 minutes ago, Robin S said:
My preference is to use <region> (or <pw-region>) tags for scripts and stylesheets.
Thanks Robin, forgot about the <region> tag. Good call!
-
I've configured my PW site to use regions and mostly it's fabulous. However I encountered a strange problem when appending scripts to the body tag of a template. The body tag id is "bodyTag" (duh!).
There are 3 scripts - two external and one inline. My first attempt was to append each script individually thinking they'd appear in the same order on the output:
<script id="googlemapskey" type="text/javascript" src="https://maps.google.com/maps/api/js?key=XXXXXXXXXXXXXXXXXXXXXX" pw-append="bodyTag"></script> <script id="localMapsJS" type="text/javascript" src="<?=$bootstrap?>js/jquery.gmap.js" pw-append="bodyTag"></script> <script type="text/javascript" pw-append="bodyTag"> jQuery(document).ready(function($){ ... }); </script>
Not so! Got lots of js errors and discovered the output had placed the scripts in the incorrect order, ie:
<script type="text/javascript" pw-append="bodyTag"> jQuery(document).ready(function($){ ... }); </script> <script id="localMapsJS" type="text/javascript" src="/site/assets/mytheme/js/jquery.gmap.js"></script> <script id="googlemapskey" type="text/javascript" src="https://maps.google.com/maps/api/js?key=XXXXXXXXXXXXXXXXXXXXXX"></script>
In other places I've appended multiple HTML regions to the same tag and it's worked fine. It only happens with scripts.
After trying a few things, I discovered a workaround which was to wrap all the scripts into one div which is then appended to the body tag. This is OK but not ideal. I think (?), the partial is rendered in its entirety before being appended to the body tag:
<div pw-append="bodyTag"> <script id="googlemapskey" type="text/javascript" src="https://maps.google.com/maps/api/js?key=XXXXXXXXXXXXXXXXXXXXXX"></script> <script id="localMapsJS" type="text/javascript" src="<?=$bootstrap?>js/jquery.gmap.js"></script> <script type="text/javascript" pw-append="bodyTag"> jQuery(document).ready(function($){ ... }); </script> </div>
Curious to know where I went wrong in the first example with each script appended individually or is this behaviour with scripts an undocumented feature of regions?
Using PW 3.0.61 with both Chrome and Firefox
-
Another way perhaps:
When you look in the database at field_pagetablefieldname you will see 3 columns -
pages_id = the page on which the PageTable appears (this is what you need)
data = the id of the PageTable page
sort = sort order for the items to appear on the pages_id page
You could hook after the new PageTable entry is saved (ie Pages::saved), and do a $database call to select the pages_id that has the newly created page id in the data field.
-
Thanks Juergen and a great suggestion re the anchor. Achieved it with Ryan's snippet:
// scroll to form submitted message jQuery(document).ready(function($) { var f = $('#FormBuilderSubmitted'); if(!f.length) return; var y = f.offset().top; $('body').animate( { scrollTop: y }, 'slow'); });
-
1
-
-
This site was one of my first PW attempts a couple of years ago. I recently upgraded it to PW 3.0.60 and changed it to delayed output rather than header/body/footer format.
URL: https://rockpoolpainting.com.au/
PW: v3.0.60
Modules:
Admin Help Page
Admin Help Setup
Admin Help Tab
Admin Save Actions
Database Backups
Email Obfuscator
File (for FormBuilder)
Form Builder
Forms
Jquery
jQuery DataTables Plugin
Json-LD Schema
Markup Simple Navigation
Markup Sitemap XML
Mobile Detect
Modules Manager
Modules Manager Notification
Page Delete
ProCache
ProFields: Table
Template Editor
Templates Reference (multiple)
Features:- To keep the home page content fresh, the list of services (repeater field) and 'Examples of our work' (Gallery page children, limit = 3) are randomly shuffled. Display changes subject to ProCache refresh.
- Testimonials are also randomly shuffled to keep content fresh
-
Submission of the testimonial form adds the form data to an unpublished item in a pagetable on the testimonials admin page so the admin doesn't have to go to Setup->Forms->testimonial->Entries to view/edit/approve/delete the new submission (thanks netcarver
)
- Framework is Bootstrap although didn't use Bootstrap profile
- All pages validate on https://validator.w3.org/
- Considering the number of images and the fact it's on a shared host, page speeds are acceptable on https://developers.google.com/speed/pagespeed/insights/
- Photos of Tuggerah are my kitchen that Chris painted
-
12
-
Had a couple of older PW 2.7 sites slow to the point of failure this week. A bit of digging revealed that the external image compression service used by ProcessImageMinimize is no longer available. Development on the module ceased some time ago.
Quick fix was to uninstall the module and edit the output code to use native PW image options. All affected sites operational again.
Next step is to update them to PW3.0+ ...
-
1
-


MarkupSimpleNavigation
in Modules/Plugins
Posted
@billjoseph
I may be missing something here but why not simply modify the outer_tpl template in $options to include the Search button? Then it would always be the last item in the menu.