We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42596
    • 45 Posts
    This also makes no difference sadly...

    The TV's definitely have values and are being retrieved.

    If on the same page I just say:

        $carId = $modx->runSnippet('getReqParam', array('name'=>'id'));
        $carResource = $modx->getObject('modResource', $carId);
        $title = $carResource->get('pagetitle');
        $price = $carResource->getTVValue('price');
        $img = $carResource->getTVValue('home-img');
        $output = $title;
        $output .= $price;
        $output .= $img;
        return $output;


    It gets the correct values and shows them...its only when I submit the form and go to the next page that it loses them somewhere.
      • 4172
      • 5,888 Posts
      what do you get on the landing-page with

      print_r($_GET);


      in your snippet?

      Then, using 'id' for the query-key isn't a good idea, use something like 'car_id'
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 42596
        • 45 Posts
        Im not sure how to print_r on the following page with the same snippet?

        Tried changing the id to car_id...no dice...

        Even if I can just send that id through alone would be good because then I should just write another snippet that gets the information I need on that page but it wont even send just that...
          • 4172
          • 5,888 Posts
          Can you explain from the beginning, what you are trying?
          Have the feeling to miss something.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 42596
            • 45 Posts
            I have a form that gets filled out and then on submit goes to a thank you page. That is the simple version.

            The thing is...on the page previous to the form I have a url which, in its raw form, looks like this:

            <a href="[[~14]]?pagetitle=[[*pagetitle]]&price=[[*price]]&carimage=[[*home-img]]&car_id=[[*id]]" class="info hover-bg">ARRANGE A VIEWING</a>


            The page with this url is about one car (of many)...

            14 is the ID of the page with the form on it. I am using the variables in the url to populate things on the form page such as the car they were looking at image, name and price...this works all fine.

            My client has requested that on the thank you page, after the form has been submit, they still want to display all the same information.

            The snippet is called on the form page. In the snippet I call a chunk that contains the form if the form !isset. If the form isset then take the details, email the client with the relevant info and then re-direct to the thank you page.

            here is the script in its entirity:

            ini_set('display_errors',1);  
            error_reporting(E_ALL);
                
                $carId = $modx->runSnippet('getReqParam', array('name'=>'car_id'));
                $carResource = $modx->getObject('modResource', $carId);
                $title = $carResource->get('pagetitle');
                $price = $carResource->getTVValue('price');
                $img = $carResource->getTVValue('home-img');
                $url = $modx->makeUrl(17,'web',array('pagetitle' => $title, 'price' => $price, 'carimage' => $img), 'full');
                
                if(isset($_POST['view-submit']) || isset($_POST['drive-submit'])){
                    if(isset($_POST['view-submit'])){
                        $arrView = "This customer is coming to you";
                    }else if(isset($_POST['drive-submit'])){
                        $arrView = "The customer wants you to come to them";
                    }
                    $subjectline = 'Somebody would like to view a car!';
                    $emailfrom = '[email protected]';
                    $message = $modx->getChunk('viewingEmailTpl', array(
                        'name' => $_POST['viewer-name'],
                        'email' => $_POST['viewer-email'],
                        'mobile' => $_POST['viewer-phone'],
                        'car' => $_POST['viewer-car'],
                        'message' => $_POST['viewer-message'],
                        'burb' => $_POST['viewer-burb'],
                        'date' => $_POST['selected-date'],
                        'time' => $_POST['selected-time'],
                        'arrView' => $arrView
                	));
                	$modx->getService('mail', 'mail.modPHPMailer');
                    $modx->mail->set(modMail::MAIL_BODY,$message);
                    $modx->mail->set(modMail::MAIL_FROM,$emailfrom);
                    $modx->mail->set(modMail::MAIL_FROM_NAME,'Name');
                    $modx->mail->set(modMail::MAIL_SUBJECT,$subjectline);
            
                	$modx->mail->address('to','[email protected]');
                	
                    $modx->mail->setHTML(true);
                    if (!$modx->mail->send()) {
                	    $modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$modx->mail->mailer->ErrorInfo);
                    }
                    $modx->mail->reset();
            
                    $modx->sendRedirect($url);
                }else{
                    $output = $modx->getChunk('arrViewForm');
                }
                
                return $output;


            This script has changed quite a lot throughout the day but essentially that is what I have been trying to do.

            Also, originally the $url var was just after the mail->reset() and I thought it being there could cause issues but moving it outside the if hasn't made any difference...although I kept it there just in case.

            Hope this clears things up!

            Thanks again for all the help! I really appreciate it! I have been pulling my hair out over this one haha...
              • 42596
              • 45 Posts
              So I thought I would try go down another route and use a session instead of passing it through the URL and this did not work either but...did the same thing as before and returned "Home" as the pagetitle which is making me think there is something incredibly wrong with my modx install or something?
                • 4172
                • 5,888 Posts
                what about doing all that with formit and formitretriever
                https://rtfm.modx.com/extras/revo/formit/formit.formitretriever
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                • discuss.answer
                  • 42596
                  • 45 Posts
                  I didnt want to re-build the form and do loads of hassle with formIt so i just ended up using javascript to get what i need, store a cookie in the browser and then get what i need from there.

                  Thanks a lot for your help anyway though...I really appreciate it!