Jump to content

Robin S

Members
  • Posts

    4,791
  • Joined

  • Days Won

    303

Community Answers

  1. Robin S's post in addHookAfter and image drag/drop on repeater causing issues was marked as the answer   
    See the screenshots below for a demo of how the Inputfield Selectize module can be used with getForPage()...
    Page with repeater field

     
    Page field using Inputfield Selectize

     
    Page field options (note: I'm recycling an existing 'headline' field as the attribute in the repeater)

     
    Edit: I'm a big fan of the new Inputfield Selectize, but if you want to use one of the other Page inputfields then have a read of this post - you'll see how the code could be adapted to use getForPage().
  2. Robin S's post in Front page editing in 3.0: headline|title was marked as the answer   
    I don't have much experience with the PW3 front-end editing features, but this seems to work:
    <?php $heading_field = $page->headline ? 'headline' : 'title'; $content .= "<h1>$page->edit($heading_field)</h1>";  
  3. Robin S's post in Images field always uses 'older/low quality' thumbnails was marked as the answer   
    I solved this - it was due to a module of mine in which I use the admin image thumbnails. I just needed to adjust the module code to account for the new default thumbnail height of 260px.
  4. Robin S's post in $fields->find("selector") to match fields of given type was marked as the answer   
    I just needed to fiddle around some more to find my answer.
    $image_fields = $fields->find("type=FieldtypeImage"); Looking at the data for a field I guess you can also find fields by id, flags, name and label. Nice!
  5. Robin S's post in Unrecognized path in Template Edit page was marked as the answer   
    I had this problem, and I believe it's caused by deleting the default lister (aka "Find"), which is something that becomes possible when Lister Pro is installed. If you have done this the solution is to create a new lister called "Lister".
    Because the default lister is used by the core it would be better if Lister Pro did not allow you to delete it, but instead made it simple to disable it for non-superuser roles. If you have other Lister Pro instances and you don't want certain roles to see the default lister you have to set up a special permission for the default lister and then not apply it to a role. There's definitely scope to make this process a bit clearer and easier for Lister Pro users.
  6. Robin S's post in How to find source of SQL error was marked as the answer   
    I resolved this issue - it was related to the default SQL mode changes introduced in MySQL 5.7
    I set sql_mode to the previous MySQL version's default of NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION and all is good now.
  7. Robin S's post in Stripping empty paragraphs was marked as the answer   
    I also hate empty paragraphs so gave this a try. Works well for me.
    This is an interesting one. There is a setting, but it doesn't work as intended. With the help of Tracy Debugger I did a bit of investigating as to why but haven't got to the bottom of it yet. The line intended to replace empty paragraphs in InputfieldCKEditor is this:
    $value = str_replace(array('<p><br /></p>', '<p> </p>', '<p></p>', '<p> </p>'), '', $value); But it doesn't match the empty paragraphs because $value has already passed through HTML Purifier where   gets replaced with some mystery space character. So neither 'nbsp;' nor ' ' match the space character between the paragraph tags. I haven't been able to work out what this space character is because it's rendered like a normal space in the variable dump.
    ---
    Update: the mystery character is a UTF-8 encoded non-breaking space character. So the code above should instead be:
    $value = str_replace(array('<p><br /></p>', '<p> </p>', "<p>\xc2\xa0</p>", '<p></p>', '<p> </p>'), '', $value); Double quotes are needed around the string with the UTF-8 non-breaking space. I'll submit a pull request for this fix.
  8. Robin S's post in WireMail Mailgun was marked as the answer   
    Thanks, all solved now as per the edit to my post. Just needed to uncheck "Enable Test Mode" in the module config.
  9. Robin S's post in CKEditor: Styling nested flow elements was marked as the answer   
    I don't think this step is necessary.
    Checking the page source of the Edit Page screen to see the rendered CKEditor config is revealing.
    For your CKEditor field: Edit Field > Input > Plugins > Remove Plugins
    Delete 'magicline' if it is shown here.
  10. Robin S's post in Sanitizer to strip tags but keep line breaks was marked as the answer   
    Solved now - $sanitizer->textarea works just fine with no options needed. I just couldn't see the line breaks because I put the plain text message in WireMail's bodyHTML.
  11. Robin S's post in Using file inputfield on frontend: reset value was marked as the answer   
    Found some helpful discussion related to this issue here.
    The value of the inputfield must be set to a Pageimages object for an existing page. By default $page is used (which isn't what is wanted for this example) but it can be changed to a different page.
    In the context of Soma's gist the fix is to add the following at the end of the "success" section:
    $form->get("myimages")->attr("value", new Pageimages($uploadpage)); So the complete success section is
    if(!count($form->getErrors())){ // if no error occured // create new page and save values $uploadpage = new Page(); $uploadpage->template = "upload-entry"; $uploadpage->parent = $pages->get("/upload-api/"); // add title/name and make it unique with time and uniqid $uploadpage->title = date("d-m-Y H:i:s") . " - " . uniqid(); $uploadpage->addStatus(Page::statusUnpublished); $uploadpage->save(); // save uploaded files to new page and remove temp files $files = explode("|",$form->get("myimages")->value); foreach($files as $file){ if($file && file_exists($upload_path . $file)){ $uploadpage->myimages->add($upload_path . $file); unlink($upload_path . $file); } } $uploadpage->save(); $form->get("myimages")->attr("value", new Pageimages($uploadpage)); $sent = true; // or better do a redirect here before showing thank you text. }
  12. Robin S's post in Anyone successfully added CKEditor shortcut keys? was marked as the answer   
    Got it sorted, and complete plugin code is:
    // Keyboard shortcuts for headings 1-6, p ( function() { CKEDITOR.plugins.add( 'keystrokes', { init: function( editor ) { editor.addCommand( 'h1', { exec: function( editor ) { var format = { element: 'h1' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.addCommand( 'h2', { exec: function( editor ) { var format = { element: 'h2' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.addCommand( 'h3', { exec: function( editor ) { var format = { element: 'h3' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.addCommand( 'h4', { exec: function( editor ) { var format = { element: 'h4' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.addCommand( 'h5', { exec: function( editor ) { var format = { element: 'h5' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.addCommand( 'h6', { exec: function( editor ) { var format = { element: 'h6' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.addCommand( 'p', { exec: function( editor ) { var format = { element: 'p' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.setKeystroke( CKEDITOR.ALT + 49 , 'h1' ); // ALT + 1 editor.setKeystroke( CKEDITOR.ALT + 50 , 'h2' ); // ALT + 2 editor.setKeystroke( CKEDITOR.ALT + 51 , 'h3' ); // ALT + 3 editor.setKeystroke( CKEDITOR.ALT + 52 , 'h4' ); // ALT + 4 editor.setKeystroke( CKEDITOR.ALT + 53 , 'h5' ); // ALT + 5 editor.setKeystroke( CKEDITOR.ALT + 54 , 'h6' ); // ALT + 6 editor.setKeystroke( CKEDITOR.ALT + 55 , 'p' ); // ALT + 7 } }); } )(); After adding the plugin it needs to be activated in the field settings > Input > Extra Plugins
    keystrokes.zip
  13. Robin S's post in Chose Img Class was marked as the answer   
    Just to expand on this a bit: unlike the standard CKEditor image plugin, the PW image plugin does not provide a text field where you can type in a class for the image. So you would need to add "img-responsive" to a custom JS styles set and apply the class to the image using the styles dropdown. Info on how to load a custom style set is here.
    If you want the "img-responsive" class to be applied to every image in your CKEditor field (so you don't have to manually add it to every inserted image) there are a couple of options:
    1. Add the class client-side with jQuery. This is a nice easy option. For example if your body text is inside a div with the class "body"...
    $(".body img").addClass("img-responsive"); 2. A little more challenging but no big deal if you're comfortable with PHP... create your own text formatter module that adds the class at runtime.
  14. Robin S's post in Selector AND, OR syntax was marked as the answer   
    $pages->find("foo=(text_field*=cat), foo=(page_field=1234), bar=(text_field*=dog), bar=(page_field=4321)"); Is that right? Anything more succinct that that possible?
  15. Robin S's post in Multi-site on shared cPanel host was marked as the answer   
    I reset the database password for site2 (I don't think it was wrong but just starting the process of double-checking things) and now I'm able to access site2 without problem. Weird, not sure why a db password problem would cause a 500 Internal Server Error. But all working now so happy joy
×
×
  • Create New...