Jump to content

RyanJ

Members
  • Posts

    207
  • Joined

  • Last visited

Posts posted by RyanJ

  1. Hi Kongo,

     Does the capability exist that allows the admin user to select from the media manager if the standard file/image field types are being used elsewhere?

    So for clarification, I am using a file and image field type and would like the ability for the user to select from both the default or the media manager gallery. This will allow me to use the existing fields without losing any of the images that already live in the assets folder.

  2. So I figured it out and here is my complete code if it would help anyone else. 

    //get the pages you want
    $items = $pages->findMany("template=item"); 
    
    wire()->addHookAfter('Pages2JSON::getValue', function($event) {
    	//get the host
       	$host = wire('config')->httpHost;
        $value = $event->arguments(0);
        if(!is_object($value))
            return;
    	//check if field is an image, images or file type
        if($value->className == 'Pageimage' || $value->className == 'Pagefile') {
    		//append the host to those values
           $urls = array("url" => $host . $value->url, "description" => $value->description);
           $event->return = $urls;
        }
            
    });
    
    header('Access-Control-Allow-Origin: *');
    header('Content-Type: application/json');
    echo $items->toJSON();
    exit();

    Thanks again for the great plugin.

    • Like 2
  3. Great module! It came in handy and saved me a lot of work from building my own JSON. Thanks!

    I do need to modify the output and I am struggling to understand how to do so.  By default, the http host is not appended to any url and I need that for this particular project. I figured this would be a simple fix, but can't find where to alter that particular value. If you reference the json below, you will see the file node with the url displayed. There are two other nodes that I need to alter the same. Images and video. Any tips are appreciated.

    //original code
    $items = $pages->findMany("template=item"); 
    echo $items->toJSON();
    {
            "pages": [
                {
                    "id": 1033,
                    "title": "Page 1"
                },
                {
                    "id": 1116,
                    "title": "Page 2"
                }
            ],
            "categories": [
                {
                    "id": 1031,
                    "title": "Brochures"
                },
                {
                    "id": 1036,
                    "title": "Photos"
                }
            ],
            "file": {
                "description": "File 1",
                "url": "/site/assets/files/1039/file1.pdf"
            },
            "id": 1039,
            "images": [],
            "modified": 1490728945,
            "title": "Test Document 1",
            "type": {
                "name": "file"
            }
        },

     

  4. It may not be in the latest version, but if so, I am assuming it would be in the same place in the modules settings page at the bottom under Spam. By default there are 5 spam fields. From your list, you are missing a few (again, this may have changed in the latest version of the module). Glancing at the latest documentation, it looks like you are missing " scf-website " field.  

    Also, check the names on your input fields in your markup. A typo could throw the error too I believe. 

  5. Look at your  anitSpamCountAdditionalInputs. I have not played with the version that is compatible for PW 3.0, but I run into this message often and usually its just an oversite of fields. Also in your markup, make sure you name fields match those in the template or else you will get that message.

  6. And are you trying to map to those fields? Also, if you are trying to set the page id and url, then this is not going to work. PW creates its own page id and url once when you do the import. You can update the url, but not out of the box using this module unless something has changed since last time I used it.

  7. Hi LostKobrakai, 

    I will be glad to write up any specific details you would like to hear about, but thought this may be a better general overview. If this does not answer your question, please let me know and I will try to be more detailed, but I am still learning how the entire migration process works myself. Since they support WordPress, it works out the box, but I don't see any reason why it would not work with PW.

    • Like 1
  8. I recently had the experience to spin up a WordPress website using pantheon web service. I got to say that I am truly impressed with the workflow it provides out of the box for WordPress and even Drupal. You get three environments to work in, Development, Stage and Production. The fact that you can pull back the production database into your development environment is such a useful tool. Would love to see PW as an option for them.

    • Like 2
  9. Hello, 

    I want to follow up with this post here as I am having the same issue. 

    In my case, I am converting a wp blog over and need to keep consistent urls by (removing /blog/) from url. I am following Ryan's methodology here.. All works great, but if I automatically include the meta in the modules settings, on my post template, all of the meta is showing up twice. If I manually try to echo the seo meta, then I get the undefined index that was mentioned in the first link I referenced. 

    Anyone else experienced such?

    SEE BELOW  :-[

  10. Do all your fields match up on your form to what the module has generated? Check your template field names against what is in the module settings. Make sure you save the module if you have updated or changed any fields.

    Also check the antiSpamCountAdditonalInputs in the module settings and make sure those fields exist in your template.

    • Like 1
  11. Thanks Wanze, the output headers was one of my issues indeed.

    I am back at it again with some issues getting custom fonts to load. In this case I have read a few topics in the forum as well as the manual here. I am attempting to include an Open Sans font. The steps I have taken are so.

    Added ttf file to modules/Pages2Pdf/mdf/ttfonts

    modified config_fonts.php 

    $this->fontdata = array(
      "dejavusanscondensed" => array(
         'R' => "DejaVuSansCondensed.ttf",
         'B' => "DejaVuSansCondensed-Bold.ttf",
         'I' => "DejaVuSansCondensed-Oblique.ttf",
         'BI' => "DejaVuSansCondensed-BoldOblique.ttf",
      ),
      "opensans" => array(
         'R' => "OpenSans.ttf",
         'B' => "OpenSansB-Bold.ttf",
         'I' => "OpenSansI-Italic.ttf",
      ),

    Changed Mode in the module settings to "s"

    Updated the Default Font in the Module Settings to "OpenSans"

    Anything stand out that I am missing?

  12. Hi Wanze, 

    That did the trick. I commented out the saving of the file and all appears to be working now (Virtual Hug). Am I write that the file call's the module needs to be included before any other files? I am assuming this has to do wit the header that has to be sent.

  13. Hi Wanze, 

    Thanks for pointing out the examples. I was hoping I could just append an id, but I have went the route you suggested. The problem I am having is actually getting the document to display. (I am getting a Failed to load PDF document message). I have a get variable set as ?pdf=1 and the pdf is being written to the folder using.

    $pdf->save($page->filesManager->path . $file_name);
    $pdf->download($file_name);

    When I download the pdf, it is perfect, but viewing it in the browser is the issue.

    Thanks for your assistance.

    Updates:: forcing a download also has the same issue

    $pdf->download($file_name, 'D');

    Update::

    This issue was where I was calling the module. It should go before the header file is included. This may or may not be the right solution, but it did to the trick for me. Although, there is some issues now with images not showing up.

  14. I am not sure the best approach for this, but suggestions are appreciated. I have created a members portal that allow each member to select some "nodes" (pages) and stores them in a page field type that I have assigned to the user template which is an admin template. They can then download the pdf containing the pages that they have selected.

    The issue is that I need to store the pdf's under each users page instead of the selected page. Is this possible? I would also really like to be able to use $user->name in the naming convention as well. I guess this would be possible using the hook you described here.

    I think just appending the user's id to the file name would do the trick for now.

    Awesome module by the way. Thanks for sharing it.

  15. This seems to work, although I am not sure it is the best solution.

    if($input->post->email && $input->post->pass) {
    $email = $sanitizer->email($input->post->email); 
       $pass = $input->post->pass;
    
       //get user name
       $who = $users->get("email=$email")->name;
       if ($who) {
        //start a session if they exist
        $user = $session->login($who, $pass);
       }
       // if they are a logged in, it must match
       if ($user) {
       echo "it matches" . "<br />";
       } else {
       echo "it does not" . "<br />";
       }
    }
  16. Bringing an old post back alive. I cannot get the user to authenticate and start a session for whatever reason in a custom login form. This form is for frontend users. I am hoping someone can see what I am missing. I am getting the user->name for the particular user though.

    if($input->post->email && $input->post->pass) {
       $email = $sanitizer->email($input->post->email); 
       $pass = $input->post->pass;
       //allow for email login
       $us = $users->find("email=$email");
       foreach($us as $u) {
         echo $u->name . "<br />";
          if($u->pass === $pass) {
            echo "it matches" . "<br />";
            $u = $session->login($u->name, $pass);
          } else {
            echo "it does not" . "<br />";
          }
       }
    }
    
  17. Hello, 

    I have modified a module that I found in this topic

    To sum it up, I have created a unique field on the root page that is called counter and is set at a unique number. when a new page is created, the module auto populates the page name and page title using this counter. The two functions renderName and CreateTitle work fine.

    What I am struggling with is how to update the counter field after the new page is created. Any suggestions or tips are appreciated

    class invoiceGenerator extends WireData implements Module {
        /**
         * getModuleInfo is a module required by all modules to tell ProcessWire about them
         *
         * @return array
         *
         */
        private $id;
    
        public static function getModuleInfo() {
    
            return array(
    
                'title' => 'Generates Invoice Number',
                'version' => 100,
                'summary' => 'Set the title field & page name to predefined value',
                'singular' => true,
                'autoload' => true,
                );
        }
        public function init() {
                $this->addHookBefore("Inputfield::render", $this, "renderName");
                $this->pages->addHookBefore('save', $this, 'createTitle');
                $this->addHookAfter('Pages::saved', $this, 'counterUpdate'); 
            }
        //create the page name
        public function renderName(HookEvent $event) {
            // get the current field
            $field = $event->object;
            if(($field->name == 'title' || $field->name == '_pw_page_name') && $field->value == '' ) {
                $counter = wire('pages')->get(1)->invoice_counter;
                $id = "WR-" . date("Y") . "-" . ($counter+1);
                $field->set('value', $id);
                //$this->log("this is page name" . $this->id);
            }
        }
        //create the page title
        public function createTitle(HookEvent $event) {
            $page = $event->arguments[0];
            
            if ($page->template == 'order') {
                $counter = wire('pages')->get(1)->invoice_counter;
                $id = "WR-" . date("Y") . "-" . ($counter+1);
                $page->title = $id;
                //$this->log("this is page name" . $this->id);
            }
        }
        //update the counter field
        public function counterUpdate(HookEvent $event) {
            $page = $event->arguments[0]; 
            $root = wire('pages')->get(1);
            $counter = $root->invoice_counter;
            $root->invoice_counter = $counter++;
            $root->save("invoice_counter"); //save the page          
              
        }
    }
    
  18. That does make sense Dave, thanks. However maybe I am misunderstanding how this fields settings works. Under the input tab on this fields settings, If I modify the "Date Input Format" to none and then modify the "Date Input Format Code" to "Y" per PHP Date then an acceptable format for this field should be the full year ie "2012". Is this not correct?

    When doing so the value reverts back to 1969 and the value stored in the DB is 1969-12-31 19:33:32

  19. I figured out the issue. User error and some default behavior in the mix. When an invalid date format is entered for example "2012", the date reverts back to 1969-12-31 after page save. I guess that is the default date input format, because if I select none, it reverts back to that. Can someone confirm this is normal behavior.

    Thanks for all the suggestions and assistance so far.

    • Like 1
×
×
  • Create New...