Jump to content

fbg13

Members
  • Posts

    344
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by fbg13

  1. @microcipcip https://processwire.com/blog/posts/processwire-2.6.7-core-updates-and-more/#new-core-files-for-site-hooks
  2. @FrancisChung you have $stats->save; instead of $stats->save(); in your code.
  3. Make sure you're not echoing $home = $pages->get("/"); too, can't think of another reason.
  4. // "/" is the home page $home = $pages->get("/"); echo $home->phone;
  5. @matjazp has forked the module with some changes to it.
  6. In PW you have pages, fields and templates. Each page can have multiple fields (text, textarea, checkboxes etc.), these fields are not assigned directly to the page but rather to a template. So you create the fields, create the template and assign the fields to the template. When you create a page you can choose a template, this way you tell the page to use the fields assigned to that template. The templates you create also need (need only if the template is used in front-end) a template file in /site/templates/ directory, so that when you access a page in the front-end PW uses that template file to display content. Do read some of the tutorials, as they explain this better: https://processwire.com/docs/tutorials/but-what-if-i-dont-know-how-to-code/ Don't know where you read about the bootstrap thing, but it can refer to two things bootstrap the css framework or this bootstrapping. OOP means Object Oriented Programming and PW is written using this way of programming.
  7. $pages->find("template=template_name, name*=whatever"); This should do it https://processwire.com/api/selectors/#operators
  8. In that directory is there a variation too or just the original image? If it just the original image then PW probably can't create the variation for some reason. I had this happen while importing some images from another site through multi-instance, in my case it was a problem with the directory ownership. You can check ownership with this command: ls -l /path/to/site/assets/files Result (web8 is the user, www-data is the apache group): You can then compare an old directory with a new one.
  9. $f4 = new Field(); $f4->type = $this->modules->get("FieldtypeOptions"); $f4->name = "name"; $f4->label = "Label"; $f4->save(); $manager = new SelectableOptionManager(); $options = 'red green blue'; // you can also set IDs and values if needed $manager->setOptionsString($f4, $options, false); $f4->save(); That did it, had to save the field before adding the options, took me a while to figure it out. Thanks for the help.
  10. What is $field['export_options'] supposed to be? Just the value from export_options of the export json? $f4 = new Field(); $f4->type = $this->modules->get("FieldtypeOptions"); $f4->name = "name"; $f4->label = "Label"; $f4->export_options = "1=on|On\n2=off|Off\n3=indexon|Index On\n4=indexoff|Index Off"; $f4->save(); I tried multiple formats but there are no options after i install the module.
  11. I'm setting up some fields in a module and i need an options field, but i can't figure out how to set its options with the api. These options:
  12. If you know html, css and php all you need is to understand the processwire api. https://processwire.com/docs/tutorials/ these are enough for someone to understand how to build a site with PW, but you have to spend a little time reading.
  13. Also check your error logs and look for the image on the server, if it's there check the permissions and ownership.
  14. Replace $pages with $this->pages or wire("pages") $p = $this->pages->get("parent=/parent-page/,title=the_title_of the_page_to_be_created_updated"); $p = wire("pages")->get("parent=/parent-page/,title=the_title_of the_page_to_be_created_updated");
  15. Why not just do foreach($categories as $item) { //get the page if it exists $p = $pages->get("parent=/parent-page/,title=the_title_of the_page_to_be_created_updated"); if($p->id){ // page exists $p->title = "new title"; $p->save(); } else { // page does not exist $np = new Page(); $np->template = "template-of-page-to-be-created"; $np->parent = $pages->get("/parent-page/"); $np->title = "the title"; $np->save(); }
  16. https://processwire.com/api/ref/sanitizer/unentities/ Never mind didn't read carefully.
  17. Updated the module to fix the above bug and some other things. Also added options to set a height for the editor, choose whether you want to include or exclude the defined extensions and the default file is now relative to the default directory.
  18. @netcarver i tested the roles and permissions and it looks like until a superuser give another role the "file-editor" permission he can't access the page at all. While testing this i discovered a bug, if the edited file contains the "</textarea>" text it will cause the text-area to close prematurely causing weird output, this is caused by code mirror. Will look into it.
  19. The problem was with the loadProcessWire() function. On the first iteration all was good, but on the second iteration PW was already loaded so the function returned nothing, resulting in the $pwm variable being null. Solved it by replacing the function with require(PW_CORE_FILE_PATH); $pwm = new \ProcessWire\ProcessWire(PW_ROOT_PATH); and calling global $pwm; instead of $pwm = loadProcessWire();
  20. Another problem. When i delete a post in WP i delete a page from PW too, the id of the PW page is stored in a meta field. The code: function loadProcessWire() { if (class_exists('\ProcessWire\ProcessWire')) return; require(PW_CORE_FILE_PATH); $ProcessWire = new \ProcessWire\ProcessWire(PW_ROOT_PATH); return $ProcessWire; } add_action( 'before_delete_post', 'deletePWPage', 10 ); function deletePWPage($post_id) { // get PW page id from meta field $pwid = get_post_meta($post_id, 'pw_post_id', true); if(!$pwid) return; $pwm = loadProcessWire(); if($pwm->pages->get("parent=/posts/, id={$pwid}")->id) { $post = $pwm->pages->get("parent=/posts/, id=".$pwid); $pwm->pages->delete($post, true); } } This works fine if i delete only one post, but if i try to delete more than one post i get Fatal Error Call to a member function get() on null When deleting multiple posts, WP creates an array with posts ids and calls the wp_delete_post($post_id) function for each id, the first iteration runs and the post is deleted as well as the PW page, so the error occurs on the second iteration. Any ideas what is going wrong? Is it PW or WP?
  21. @adrian I know what you meant. Just that i built this to learn and don't know how much i will further improve this module, that's why maybe the development sub-forum might have been a better fit.
  22. I did this mostly to learn how to create a module with settings and a PW admin page. Maybe it would fit better in the Module/Plugin Development sub-forum.
  23. File Editor GitHub https://github.com/f-b-g-m/ProcessFileEdit matjazp version https://github.com/matjazpotocnik/ProcessFileEdit A module that allows you to edit file directly in the in the admin area. First module and first time doing a file editor so the way i do it might not be the best. Feedback is welcome. Editor page Setting page
  24. I'm using the multi-instance feature of PW to create a page from the wordpress admin and after the page is created i save its id in a custom meta field in wp. The page should be created/updated when a post is first created or updated through wp's post_updated hook. Here is the code: The page is created in PW but its id is not saved in wp custom meta field. If i comment the "$p->save();" line i don't get the error, but i obviously need it. On localhost it works, but on the server i get the error; same PW, WP (same plugins) and PHP version, only the os differs, Windows on localhost and Debian on the server. Any ideas? Update: I used the site profile exporter module to move from localhost to the live server and it seems like this was the cause as everything worked after i manually set up the templates and fields on a clean install. I did uncheck the installed checkbox from the module's options. Could that be the reason?
  25. Take a look here I haven't read it all but it covers what you need to some extent.
×
×
  • Create New...