-
Posts
4,928 -
Joined
-
Days Won
321
Everything posted by Robin S
-
[Solved] Permission problem – no access to /site/assets/
Robin S replied to rash's topic in Getting Started
Your permission issues may be affecting all PW files. This error... Compile Error: require_once(): Failed opening required '~/site/modules/TextformatterTextile/src/Parser.php' (include_path='~/wire/modules/Markup/MarkupHTMLPurifier/htmlpurifier/standalone:.:/usr/share/php:..') (line 39 of ~/site/modules/TextformatterTextile/TextformatterTextileField.module) ...relates to a file outside /site/assets/. So when you are testing the change of owner you should do this for all PW files. -
@LMD, thanks for the report. Please update to v.0.04 where this issue should be fixed.
-
If people come up with any nifty usages of HannaCodeDialog it would be cool to get a bit of a library going in this thread. Here's one to get the ball rolling. Select FormBuilder form For the foolproof selecting of a FormBuilder form to embed in a CKEditor field. Import both of the export strings to use this. The code is shown here just for reference. _formbuilder_forms Export string (import this into Hanna Code): !HannaCode:_formbuilder_forms:eyJuYW1lIjoiX2Zvcm1idWlsZGVyX2Zvcm1zIiwidHlwZSI6IjIiLCJjb2RlIjoiPD9waHBcbmVjaG8gaW1wbG9kZSgnfCcsIGl0ZXJhdG9yX3RvX2FycmF5KCRmb3Jtcy0+Z2V0SXRlcmF0b3IoKSkpOyJ9/!HannaCode Code (just for reference): <?php echo implode('|', iterator_to_array($forms->getIterator())); select_form Export string (import this into Hanna Code): !HannaCode:select_form:eyJuYW1lIjoic2VsZWN0X2Zvcm0iLCJ0eXBlIjoiMiIsImNvZGUiOiJcLypoY19hdHRyXG5mb3JtPVwiXCJcbmZvcm1fX29wdGlvbnM9XCJbW19mb3JtYnVpbGRlcl9mb3Jtc11dXCJcbmhjX2F0dHIqXC9cbjw/cGhwXG5pZigkZm9ybSkgZWNobyBcIjxwPmZvcm0tYnVpbGRlclwvJGZvcm08XC9wPlwiOyJ9/!HannaCode Code (just for reference): <?php if($form) echo "<p>form-builder/$form</p>";
-
Did you clear the ProCache document cache? Still seeing the missing content issue in "Book recommendations" and the malformed Goodreads link. Column layout is fixed though.
-
I am referring to the Books parent page: https://ricardo-vargas.com/books/ Edit: we posted simultaneously
-
What's up is that the size() method accepts a 'quality' setting in its $options array: https://processwire.com/api/ref/pageimage/size/ And you can define the default quality setting used for the image sizer in /site/config.php via $config->imageSizerOptions: https://processwire.com/api/ref/config/
-
I tested in Firefox and Chrome on Windows. But I would expect the same for all browsers because the issues are in the source code. Odd that you don't see them at your end - maybe I'm seeing cached content and you're not. 1. "Book recommendations" item missing expected content - probably just needs some if() conditions. 2. Side column: you have a mismatch between large/medium column classes, meaning the side column wraps under the main column but remains narrow at medium device width. 3. Goodreads link
-
FYI: I just checked the LoginPersist module and it's working for me in PW3.
-
Nice work! Must be a good feeling to have such a big task completed and live. I'm always interested to hear how much time goes into larger jobs like this undertaken by a single developer: any idea how long you spent on it? I noticed a couple of minor display issues on the Books page. You can see both in the screenshot below: "Book recommendations" item seems to be missing expected content. Side column layout issue at some device widths. Edit: one more on this page... the "Powered by Goodreads" link is malformed. Again, a really great site.
-
Not in this fieldtype as it stands because it only has a single inputfield. But you can create other fields for the purpose and add them to your template, maybe grouped inside a fieldset together with the Assisted URL field. Text fields for title and rel, and maybe a Select Options field would be good for target.
-
@tpr, another idea/request: if the "permanent delete" option for Page List is checked then there is also an option to permanently delete the page from the Delete tab of Page Edit. Thanks!
-
It requires a couple of steps, but so long as your pages selector doesn't return a huge number of results this should be fairly low impact: $value = 'Foo'; $all_matches = $pages->find("my_table.my_field=$value"); $first_row_matches = $pages->newPageArray(); foreach($all_matches as $match) { if($match->my_table->first()->my_field == $value) $first_row_matches->add($match); }
-
AddHookAfter("save"...) on Page template ==("")
Robin S replied to Mathroth's topic in Module/Plugin Development
Needs the Pages class in there somewhere. Either: public function ready() { if($this->page->template->name == 'TemplateName') { $this->pages->addHookAfter('save', $this, 'syncMobileDE'); } } Or: public function ready() { if($this->page->template->name == 'TemplateName') { $this->addHookAfter('Pages::save', $this, 'syncMobileDE'); } } -
Try Pageimages::add($item)... $user->userimage->add($upload_path . $files[0]);
-
@tpr, I often want to work with system templates. Examples being: Add fields to the user template, and want easy access to the template from the admin menus or without having to set the "Show system templates" filter in the templates list. When editing a field, add that field to the template of a repeater field. Normally to do stuff like this you have to have $config->advanced = true in /site/config.php, but I don't want the risk of messing up the other things that this setting exposes. So I looked at making system templates visible through hooks and came up with this: // Show system templates $this->addHookBefore('ProcessField::buildEditFormInfo', function($event) { // Show system templates in templates list of Edit Field $this->wire('config')->advanced = true; }); $this->addHookBefore('ProcessTemplate::executeNavJSON', function($event) { // Show system templates in admin menu $this->wire('config')->advanced = true; }); $this->addHookAfter('Session::loginSuccess(roles=superuser)', null, function($event) { // Show system templates in templates list unless explicitly hidden $this->wire('session')->set('ProcessTemplateFilterSystem', 1); }); Is this something you think would be a good option to add to AOS?
-
Loading field options into inputfieldSelect
Robin S replied to Marcel Stäheli's topic in API & Templates
To add the 'country' field you can simply do this: $inputfield = $user->getInputfields('country'); $form->add($inputfield); Depending on how many fields in your user template, when building a profile edit form for the frontend it can be easier to define an array of 'ignore' fields and then add all inputfields for the user template that are not in the ignore array. Pretty sure I got this idea from some code by @Soma. // Get the fields from the user template $inputfields = $user->getInputfields(); // Don't include these fields in the form $ignore_fields = [ 'user_name', 'temp_password', 'roles,' ]; // Add the inputfields to the form foreach($inputfields as $inputfield) { if(in_array($inputfield->name, $ignore_fields)) continue; $form->add($inputfield); } -
Just reporting back that for my case this turned out to be very easy using just WireHttp alone and no Oauth client library needed. $http = new WireHttp(); $consumer_key = 'my_key'; $consumer_secret = 'my_secret'; $auth_token = 'my_auth_token'; $auth_token_secret = 'my_auth_token_secret'; $time = time(); $nonce = md5(uniqid(microtime())); // OAuth authorization header $http->setHeader('Authorization', "OAuth oauth_consumer_key=$consumer_key, oauth_token=$auth_token, oauth_version=1.0, oauth_timestamp=$time, oauth_nonce=$nonce, oauth_signature_method=PLAINTEXT, oauth_signature={$consumer_secret}%26{$auth_token_secret}"); // Parameters $params = [ 'member_listing' => '123456', 'rows' => '20', 'photo_size' => 'FullSize', 'return_metadata' => 'false', ]; $params_str = http_build_query($params); // Get JSON response from Trade Me $json = $http->getJSON("https://api.tmsandbox.co.nz/v1/Search/Property/Rental.json?$params_str"); Because of the circumstances of my case I can hardcode $auth_token and $auth_token_secret. But more often with OAuth you would need to get these values in a separate query and store them.
- 1 reply
-
- 4
-
Looks mostly good to me. My thoughts... If I'm understanding your code correctly (it would be clearer if you used a separate forum code block for each separate file) I think the code that builds the selector would be better placed in your search template (search.php) rather than in your search-form.php include. I think this would solve some of your concerns, and also allows you to create links to the search results page that don't come via the search form (e.g. suppose you had a page that listed a link for each town to show results for that town). If your search form appears on the search results page you just need to make sure the code that builds the selector is above the search-form.php include so that the whitelist variables have been populated. This part... $townSelectorPart = ""; foreach ($towns as $town) { $townSelectorPart .= $town . "|"; } $townSelectorPart = rtrim($townSelectorPart, "|"); ...could be shortened to... $townSelectorPart = implode('|', $towns); I think it's okay to use an unsanitized GET variable if you are using it only to check if that variable is present.
-
Super-useful video and your command of English is really impressive: you are more articulate than many native speakers! It's very slick what the GraphQL devs have done with the GraphiQL tool - so nice having the documentation explorer right there inside the tool. Thanks for the video, and also a separate thanks for updating the Skyscrapers profile and making the export of that available. Would it be okay to mention your repo of that over in the Skyscrapers Profile thread so people can use it until we have an official profile release by Ryan?
-
Adding a file to Pagefiles and saving to Database
Robin S replied to ethanbeyer's topic in API & Templates
The $field argument supplied to $page->save() must be a field name or field object. But in your example $files is neither of these (it will be a Pagefiles object). -
Cool, thanks @BitPoet.
-
If you have a "one video per page" setup then again you could dynamically generate options using another Hanna tag: get all children of "video pool" that have a video uploaded to them.
-
First time with Markup Regions - no luck getting it to work
Robin S replied to evanmcd's topic in General Support
The following quote from the blog post is useful in understanding how your templates need to be structured in order for Markup Regions to work: So the general rule is: the place where you define your 'original' markup regions (that you will append to, etc, in your template files) needs to have the doctype or <html> element in it, and it needs to be the last piece of markup to be rendered. That's why your markup regions would typically be originally defined in an auto-appended "_main.php" so that it is rendered last, and any markup that you are echoing or outputting in your template files will reference those regions and appear before the doctype/<html> of _main.php. -
I'm working on a module where I iterate over all fields in a template, and wanting to minimise the number of different field value types I need to account for. Is there a way to get the value of a 'single' Page field as a PageArray, so the value of the field is of the same type as a 'multiple' Page field? With single/multiple Image and File fields I can use getUnformatted() to ensure I always get the field value as a WireArray. I thought there might be something similar possible for Page fields.
-
@ottogal, you are right - this module will not cover your way of using HannaCode. But if you only needed to select from videos uploaded to the current page instead of letting the editor choose another page (or alternatively from one page that contains all videos), you could adapt the approach I show in the first post for creating select options from images on the page.