-
Posts
10,912 -
Joined
-
Last visited
-
Days Won
349
Everything posted by adrian
-
Front-end inline editing, so close...I think.
adrian replied to Danjuan09's topic in API & Templates
I haven't read through your code yet, but have you seen this module: http://modules.processwire.com/modules/inline-editor/ It is listed as proof of concept, but it might work for you, or help you solve the problems with your code. There is of course also Fredi: http://modules.processwire.com/modules/fredi/ and AdminBar: http://modules.processwire.com/modules/admin-bar/ - even though they are not inline, they do make front-end editing easy. -
If I understand correctly, this could be done easily with a page field added to the user template. To access the user template, go to the templates page and click Filter > Show System Templates. The Page field (probably ASM Select) that you add would be linked to all the film pages. So you'd just select the films they are allowed to view. Then in your template files you can check whether the user has the film selected before showing it in the list of films for them to watch. Let me know if anything there doesn't make sense. EDIT: Of course it could also be done from the other direction. The template for the films could have a page field that contains a list of all the users and you could choose which users can view the film. You might want to consider PageAutocomplete as the Inputfield type if you end up with a lot of films / users.
-
Thanks to Soma: https://processwire.com/talk/topic/3875-module-to-add-userid-to-pages-and-control-edit-permissions/?p=37915 Also check out the revised version a few posts below from pogidude. And also this version from tinacious: https://processwire.com/talk/topic/3271-can-i-limit-page-editing-to-the-user-that-created-that-page/?p=32121
-
batch change value per language in FieldtypeTextareas fields
adrian replied to bbeer's topic in API & Templates
Oh I see - you are using a textareas field - sorry, I read textarea, not the plural. What about: $p->prod_features_multi->prod_rating_operating_voltage->setLanguageValue($en, 'test'); BTW, I am sure it works fine, but why: if((string)$p == "1798"){ and not: if($p->id == 1798){ EDIT: Are you using the new multilanguage version of the textareas fieldtype? Also, maybe this question should be posted in the support thread for Profields - that way it will get Ryan's attention for sure. -
batch change value per language in FieldtypeTextareas fields
adrian replied to bbeer's topic in API & Templates
I am no multi language expert, but i think you need this: $p->prod_rating_operating_voltage->setLanguageValue($en, 'test'); -
Creating admin tab to download file
adrian replied to MadHatter's topic in Module/Plugin Development
I am also not sure if using die/exit is the only way, but it is what I used in my Table CSV Export/Import module: https://processwire.com/talk/topic/7905-profields-table-csv-importer-exporter/ - see the "Export as CSV" button at the bottom of the first screenshot. The one thing in that module that you might find useful in this module is the hidden iframe technique I used to make the download work without the need to open an extra page: https://github.com/adrianbj/TableCsvImportExport/blob/master/TableCsvImportExport.module#L191 Take a look at the JS file in that module to see how I am modifying the src of the iframe on the fly when the Export button is clicked: https://github.com/adrianbj/TableCsvImportExport/blob/master/TableCsvImportExport.js#L6 Hopefully you might find something to copy, or maybe someone else will have a better idea!- 1 reply
-
- 2
-
Hi Tom, I don't fully understand what you have done, but if I was trying to run two sites with one in a subfolder of the other I would also set up a subdomain: theory.example.com and an apache virtual host that points to that subfolder when called via the subdomain. Is there any reason you need the url to be www.example.com/theory rather than theory.example.com? You could do some redirects if needed.
-
Well I am trying - wish I wasn't failing you though One thing I just noticed is that you can remove all occurrences of $this - with this code in a template, you just need $input->post...... I have no idea why this would make a difference, but have you tried: $np->set($f->name, $input->post->{$f->name}); Both work for me, and the $form way is better, but thought this might help us debug.
-
Definitely working for me, but it sounds like you problem might be that the template from the page that is being used to create the form doesn't have a title field. Is that right? You need to give a page a title or at least a name - name will be created from the title if it is provided, but the name isn't. How are you planning on setting the name/title for the created pages? Have you tried debugging what part of that line is causing the error? Is it $f->name or $form->get($f->name)->value - try replacing each one with fixed values to see where the problem actually is. Yes you are right - you need to save the page before adding fields to it. Are you making use of the automatic page name option? Is that why it is being given a title of date/time?
-
Output formatting of admin messages changed
adrian replied to winston's topic in Module/Plugin Development
I don't think I ever tried to output html in messages in the existing message/error system, but with the new notifications system, it is easy: $this->user->notifications->message("Message Title")->html("Message details including a <a href=''>link</a>"); You will need to enable the new core notifications module. -
To be fair to WP, this is not a vulnerability with the core code, but rather an issue with a 3rd party plugin: http://codecanyon.net/item/slider-revolution-responsive-wordpress-plugin/2751380 I haven't read the details of the issue, so perhaps some stronger core code might have prevented this, but it doesn't matter how good the core code is, a plugin/module can be a vector for security issues in even the most secure core code.
-
Just a quick comment - not sure if this is exactly the same problem or not: https://github.com/ryancramerdesign/ProcessWire/issues/663 I think there still needs to be some work done for a proper fix. If you think it is the same issue, would you mind commenting there, or if not, maybe post a new issue.
-
I haven't used it, but take a look at this module: http://modules.processwire.com/modules/inline-editor/ Keep in mind that it is listed as a proof of concept. The other options which are much more mature, but not exactly inline, are: http://modules.processwire.com/modules/fredi/ http://modules.processwire.com/modules/admin-bar/ Hope that helps.
- 1 reply
-
- 2
-
Sorry about all that - shouldn't try offering advise with browser written code. This works fine for me: $page_id = (int) $input->post->select_product; // page ID $p = $pages->get($page_id); $template = $p->template->name; // this is the template where we will get the fields from // make a form $form = $modules->get('InputfieldForm'); $form->method = 'post'; $form->action = './'; $form->attr("id+name",'subscribe-form'); // add the page's fields to the form $fields = $p->fieldgroup; foreach($fields as $field) { $inputfield = $fields->{$field->name}->getInputfield($p); $form->append($inputfield); } // add template name field to the form $field = $modules->get("InputfieldHidden"); $field->attr('id', 'Inputfield_template_name'); $field->attr('name', 'template_name'); $field->value = $template; $form->append($field); // append the field // add a submit button to the form $submit = $modules->get('InputfieldSubmit'); $submit->name = 'save_new_aanvraag'; $submit->attr("value", "Go"); $form->append($submit); // process the form if it was submitted if($this->input->post->save_new_aanvraag) { // now we assume the form has been submitted. // tell the form to process input from the post vars. $form->processInput($this->input->post); // see if any errors occurred if( count( $form->getErrors() )) { // re-render the form, it will include the error messages echo $form->render(); } else { // successful form submission $np = new Page(); // create new page object $np->template = $form->get("template_name")->value; // set template $np->parent = $pages->get('/aanvraag/'); // set the parent $np->of(false); // turn off output formatting before setting values $np->save(); foreach($np->fields as $f) { $np->set($f->name, $form->get($f->name)->value); } $np->save(); //create the page echo "<p>Page saved.</p>"; } } else { echo $form->render(); } The one thing missing is sanitizing of user input. You should read through: http://processwire.com/api/variables/sanitizer/ This is also a good read: https://processwire.com/api/variables/input/
-
I think the building of the form the way you are doing should work, and I think it is, correct? But just for something a little cleaner, this is how I always do it: $p = $pages->get($page_id); // make a form $form = $modules->get('InputfieldForm'); $form->method = 'post'; $form->action = './'; $form->attr("id+name",'subscribe-form'); $fields = $p->getInputfields(); foreach($fields as $field){ $form->append($field); } echo $form->render(); Now to the issue of the fields not being added to the new page: It shouldn't matter, but to be more obvious, I would call your new page: $np This should do what you need - you need to iterate through the fields of the new page. $np = new Page(); $np->template = $form->get("template_name")->value; // set template $np->parent = $pages->get('/aanvraag/'); // set the parent $np->of(false); // turn off output formatting before setting values foreach($np->fields as $f) { $np->set($f->name, $form->get($f->name)->value); } $np->save();
-
Custom image upload broken after upgrade to 2.5.3
adrian replied to chrizz's topic in API & Templates
That all sounds very cool, but I think you might avoid future issues with code changes by creating a module that hooks into the standard PW upload process, rather than having a custom upload form. Sorry, I don't have much time right now to investigate why the width is not being captured for your custom upload. Pagefile::install or InputfieldFile::processInputAddFile might be appropriate methods to hook. -
Hi Marc Here a few things I see that need fixing: $page_id = htmlspecialchars($_POST['select_product']); // page ID You should use (int) instead of htmlspecialchars - that is the safest way to sanitize a page id. You shouldn't overwrite $page, so change: $page = $pages->get($page_id); to: $p = $pages->get($page_id); I think you want: $template = $page->template; // this is the template where we will get the fields from to be: $template = $page->template->name; // this is the template where we will get the fields from That will mean that your hidden field is storing the name of the template, rather than the template object. Also, you are using: $form->processInput($this->input->post); But then still using: $p->template = $input->post->template_name; // set template when you could be using: $p->template = $form->get("template_name"); // set template Hopefully that should get things working for you, although it is only: $template = $page->template->name; that is critical.
-
Hi @mrkhan and welcome to the forums. Not sure if it is the only issue, but the most obvious problem I see with your code is: $menu_page->page-tile You can't have dashes in field names, and I am also assuming it is the title of the page you are looking for. Have you tried: $menu_page->title
-
Admin update messages won't disappear after update to 2.5.10
adrian replied to owzim's topic in General Support
Sorry, I forgot that notifications are still not enabled by default. That is a weird one You seem to be having the same issue as gebeer: https://processwire.com/talk/topic/8152-notice-undefined-index-searchfields-after-update-to-25-dev/?p=78973 -
Admin update messages won't disappear after update to 2.5.10
adrian replied to owzim's topic in General Support
Looks like you are missing the notifications "bug", which shows the number of notifications. Click on it and the messages will collapse. Maybe do a hard reload to clear the browser cache - I am assuming a JS file needs updating, but just a guess. -
This is the bit in .htaccess that blocks access to files in the templates directory: # Block access to any PHP or markup files in /site/templates/ RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$ [OR] Which is why css, js etc work, but php, html, tpl, inc etc don't.
-
Just wanted to let you guys know that I have submitted a PR to Ryan to fix this issue: https://github.com/ryancramerdesign/ProcessWire/pull/823 Along with this, I wanted to note somewhere (for now here, although I will probably write a PW SVG tutorial sometime soon) that if you want to embed SVGs into CkEditor RTE fields and be able to drag to resize them, you need to add the following to the "Extra Allowed Content" section on the Input tab of the field: img[alt,!src,width,height] This allows the img tags to have width and height attributes, which allows you to resize the image to a fixed number of pixels.
-
Custom image upload broken after upgrade to 2.5.3
adrian replied to chrizz's topic in API & Templates
Thanks for the code. Have you tried logging: $pagefile->url just before the if(!$pagefile->width) { just so you can know for certain what file it getting to that point. I am also wondering about this custom upload form - what does it actually do when the image is uploaded? Seems to me that it might be easier to hook into fileAdded (or similar) and make the changes that way, rather than replace the upload form entirely. -
I haven't followed through this completely, but in your last code example, you foreach($muzikanten as $muzikant) { but then you never do anything with $muzikant That doesn't seem right!
-
@kd.quantum - firstly, sorry for the bad start to your PW experience. Firstly, can you please confirm the versions of PW and FormBuilder that you are running. Maybe there is a conflict there, if PW was updated, but FB wasn't. Looking at that error message, it is coming from line#176 of ProcessFormBuilder.module I get the feeling that since the ID is 0, that the (int) statement in that function might be converting a string or an empty value to the 0. Could you please try getting the value of $id before it has (int) applied - that might help us track down the issue a little better. Hopefully Ryan will get back to you shortly, but in the meantime, this info might help the rest of us to get you up and running again.