In CAKEPHP Check content of all view and send mail if not ok












0















With cakephp 2.9 I have this need:



I should check if there is a specific tag on the page that appears.



if it is present, must not do anything else must send me an email.



At this point I think to create a helper and recall a method in the default.ctp



with something like:



$s = this-> fetch (‘content’);
$result_check = $this->myHelper->debug_content ($s);
echo $s;


In the myHelper the function:



public function debug_content( $s) { 
$pos = strpos ( $s, "<div class = "box-body">");
if ( $pos === false) { echo “Error tag is not present!”;
return false;
}


In the AppController:



public $helpers = array (…, ‘myHelper’);


and up to here ok … but now?



How do I recall the component Email (personalized by me) to send an email?



And where do I call it?



How would you do?



Thank you,



Max










share|improve this question





























    0















    With cakephp 2.9 I have this need:



    I should check if there is a specific tag on the page that appears.



    if it is present, must not do anything else must send me an email.



    At this point I think to create a helper and recall a method in the default.ctp



    with something like:



    $s = this-> fetch (‘content’);
    $result_check = $this->myHelper->debug_content ($s);
    echo $s;


    In the myHelper the function:



    public function debug_content( $s) { 
    $pos = strpos ( $s, "<div class = "box-body">");
    if ( $pos === false) { echo “Error tag is not present!”;
    return false;
    }


    In the AppController:



    public $helpers = array (…, ‘myHelper’);


    and up to here ok … but now?



    How do I recall the component Email (personalized by me) to send an email?



    And where do I call it?



    How would you do?



    Thank you,



    Max










    share|improve this question



























      0












      0








      0








      With cakephp 2.9 I have this need:



      I should check if there is a specific tag on the page that appears.



      if it is present, must not do anything else must send me an email.



      At this point I think to create a helper and recall a method in the default.ctp



      with something like:



      $s = this-> fetch (‘content’);
      $result_check = $this->myHelper->debug_content ($s);
      echo $s;


      In the myHelper the function:



      public function debug_content( $s) { 
      $pos = strpos ( $s, "<div class = "box-body">");
      if ( $pos === false) { echo “Error tag is not present!”;
      return false;
      }


      In the AppController:



      public $helpers = array (…, ‘myHelper’);


      and up to here ok … but now?



      How do I recall the component Email (personalized by me) to send an email?



      And where do I call it?



      How would you do?



      Thank you,



      Max










      share|improve this question
















      With cakephp 2.9 I have this need:



      I should check if there is a specific tag on the page that appears.



      if it is present, must not do anything else must send me an email.



      At this point I think to create a helper and recall a method in the default.ctp



      with something like:



      $s = this-> fetch (‘content’);
      $result_check = $this->myHelper->debug_content ($s);
      echo $s;


      In the myHelper the function:



      public function debug_content( $s) { 
      $pos = strpos ( $s, "<div class = "box-body">");
      if ( $pos === false) { echo “Error tag is not present!”;
      return false;
      }


      In the AppController:



      public $helpers = array (…, ‘myHelper’);


      and up to here ok … but now?



      How do I recall the component Email (personalized by me) to send an email?



      And where do I call it?



      How would you do?



      Thank you,



      Max







      cakephp cakephp-2.9






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 11:11









      burzum

      22.8k83460




      22.8k83460










      asked Nov 16 '18 at 9:11









      Massimo De PoliMassimo De Poli

      84




      84
























          2 Answers
          2






          active

          oldest

          votes


















          0














          I dont know if I got your question right. But you can implement the needed e-mail sending function into your function where you are checking for the tag.



           App::uses('CakeEmail', 'Network/Email');

          public function debug_content( $s) {
          $pos = strpos ( $s, "<div class = "box-body">");
          if ( $pos === false) { echo “Error tag is not present!”;
          $Email = new CakeEmail();
          $Email->emailFormat('html');
          $Email->template('default');
          $Email->from('sending@adress.com');
          $Email->to('receiving@adress.com');
          $Email->subject('YOUR SUBJECT');
          $Email->send();
          return false;
          }





          share|improve this answer
























          • thank you! I solved!!

            – Massimo De Poli
            Nov 20 '18 at 10:38



















          0














          Implement a listener for the View.afterRenderFile event and see if this solves the issue. Have a look at the source code of the View class, you can see that this callback receives the view file name and the evaluated contents during the call to View::render(). You can then use this listener to check the contents for your tag and send that email if necessary.






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334646%2fin-cakephp-check-content-of-all-view-and-send-mail-if-not-ok%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I dont know if I got your question right. But you can implement the needed e-mail sending function into your function where you are checking for the tag.



             App::uses('CakeEmail', 'Network/Email');

            public function debug_content( $s) {
            $pos = strpos ( $s, "<div class = "box-body">");
            if ( $pos === false) { echo “Error tag is not present!”;
            $Email = new CakeEmail();
            $Email->emailFormat('html');
            $Email->template('default');
            $Email->from('sending@adress.com');
            $Email->to('receiving@adress.com');
            $Email->subject('YOUR SUBJECT');
            $Email->send();
            return false;
            }





            share|improve this answer
























            • thank you! I solved!!

              – Massimo De Poli
              Nov 20 '18 at 10:38
















            0














            I dont know if I got your question right. But you can implement the needed e-mail sending function into your function where you are checking for the tag.



             App::uses('CakeEmail', 'Network/Email');

            public function debug_content( $s) {
            $pos = strpos ( $s, "<div class = "box-body">");
            if ( $pos === false) { echo “Error tag is not present!”;
            $Email = new CakeEmail();
            $Email->emailFormat('html');
            $Email->template('default');
            $Email->from('sending@adress.com');
            $Email->to('receiving@adress.com');
            $Email->subject('YOUR SUBJECT');
            $Email->send();
            return false;
            }





            share|improve this answer
























            • thank you! I solved!!

              – Massimo De Poli
              Nov 20 '18 at 10:38














            0












            0








            0







            I dont know if I got your question right. But you can implement the needed e-mail sending function into your function where you are checking for the tag.



             App::uses('CakeEmail', 'Network/Email');

            public function debug_content( $s) {
            $pos = strpos ( $s, "<div class = "box-body">");
            if ( $pos === false) { echo “Error tag is not present!”;
            $Email = new CakeEmail();
            $Email->emailFormat('html');
            $Email->template('default');
            $Email->from('sending@adress.com');
            $Email->to('receiving@adress.com');
            $Email->subject('YOUR SUBJECT');
            $Email->send();
            return false;
            }





            share|improve this answer













            I dont know if I got your question right. But you can implement the needed e-mail sending function into your function where you are checking for the tag.



             App::uses('CakeEmail', 'Network/Email');

            public function debug_content( $s) {
            $pos = strpos ( $s, "<div class = "box-body">");
            if ( $pos === false) { echo “Error tag is not present!”;
            $Email = new CakeEmail();
            $Email->emailFormat('html');
            $Email->template('default');
            $Email->from('sending@adress.com');
            $Email->to('receiving@adress.com');
            $Email->subject('YOUR SUBJECT');
            $Email->send();
            return false;
            }






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 20 '18 at 8:31









            q-jackq-jack

            96212




            96212













            • thank you! I solved!!

              – Massimo De Poli
              Nov 20 '18 at 10:38



















            • thank you! I solved!!

              – Massimo De Poli
              Nov 20 '18 at 10:38

















            thank you! I solved!!

            – Massimo De Poli
            Nov 20 '18 at 10:38





            thank you! I solved!!

            – Massimo De Poli
            Nov 20 '18 at 10:38













            0














            Implement a listener for the View.afterRenderFile event and see if this solves the issue. Have a look at the source code of the View class, you can see that this callback receives the view file name and the evaluated contents during the call to View::render(). You can then use this listener to check the contents for your tag and send that email if necessary.






            share|improve this answer




























              0














              Implement a listener for the View.afterRenderFile event and see if this solves the issue. Have a look at the source code of the View class, you can see that this callback receives the view file name and the evaluated contents during the call to View::render(). You can then use this listener to check the contents for your tag and send that email if necessary.






              share|improve this answer


























                0












                0








                0







                Implement a listener for the View.afterRenderFile event and see if this solves the issue. Have a look at the source code of the View class, you can see that this callback receives the view file name and the evaluated contents during the call to View::render(). You can then use this listener to check the contents for your tag and send that email if necessary.






                share|improve this answer













                Implement a listener for the View.afterRenderFile event and see if this solves the issue. Have a look at the source code of the View class, you can see that this callback receives the view file name and the evaluated contents during the call to View::render(). You can then use this listener to check the contents for your tag and send that email if necessary.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 21 '18 at 21:56









                Timur AsalievTimur Asaliev

                763




                763






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334646%2fin-cakephp-check-content-of-all-view-and-send-mail-if-not-ok%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Bressuire

                    Vorschmack

                    Quarantine