Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Countdown 1.2.0

I am trying to add the Countdown capability to a page created with Livid Tech's "Basic Pages" application. However, nothing seems to happen. It does however work flawlessly in a forum discussion :-)

Is there a workaround to enable the function in pages created using the Basic Pages plugin?

Best regards,
N-

Comments

  • Options
    peregrineperegrine MVP
    edited September 2013

    Three ways:

    • First way

    If you want A countdown clock on all of your BasicPages - here is a sample.

    It throws the counddown timer in page (but not via [COUNTDOWN]
    
        in classcountdown.plugin.php
    
        before line
        public function Base_AfterCommentFormat_Handler($Sender) {
    
    
        add these lines ---
    
            public function PageController_BeforePageFormatBody_Handler($Sender) {
               // if (you could restrict the time getting displayed by testing for appropriate url) {  
                DisplayTimer = "Y";
              //    }
    
              if ($DisplayTimer == "Y") {
                 $Timer  = $this->DoReplacement("[COUNTDOWN]");
                  echo  $Timer;
                  } 
    
            }
    
    
    the last lines in the index.php in the basicpages/views/page/index.php
    
    change 
    
    ` <div id="PageBody"><?php echo $FormatBody; ?></div>`
    
    to
    
         <div id="PageBody">
           <?php 
          Gdn::Controller()->FireEvent('BeforePageFormatBody'); 
           echo $FormatBody; ?>
    
           </div>
        </div>
    

    • Second Way

      You could also do something like this (if you put [COUNTDOWN] in your text box.

      the last lines in the index.php in the basicpages/views/page/index.php

      change

      <div id="PageBody"><?php echo $FormatBody; ?></div>

      to

       <div id="PageBody">
         <?php 
        Gdn::Controller()->FireEvent('BeforePageFormatBody'); 
         echo $FormatBody; ?>
      
         </div>
      </div>
      

      in classcountdown.plugin.php

      public function PageController_BeforePageFormatBody_Handler($Sender) {
          $TestBody = ($Sender->Data('PageData')->Body);
          preg_match("/\[COUNTDOWN\]/", $TestBody, $Match);
          if ($Match) {
          $Timer  = $this->DoReplacement("[COUNTDOWN]");
            echo  $Timer;
          }
      }
      

      but you would need to strip [COUNTDOWN] from $FormatBody after the firevent and before the echo in index.php.


    • Third Way - the countdown tag will automatically strip out because you use <COUNTDOWN>
      in textbox in apps.

      A third way is this...
            in classcountdown.plugin.php
      
              before line
              public function Base_AfterCommentFormat_Handler($Sender) {
      
      
              add these lines ---
      
      
      
              public function PageController_BeforePageFormatBody_Handler($Sender) {
                  $TestBody = ($Sender->Data('PageData')->Body);
                  preg_match("/\<COUNTDOWN\>/", $TestBody, $Match);
                  if ($Match) {
                  $Timer  = $this->DoReplacement("[COUNTDOWN]");
                    echo  $Timer;
                  }
              }
      
      add 
      
              the last lines in the index.php in the basicpages/views/page/index.php
      
              change 
      
              ` <div id="PageBody"><?php echo $FormatBody; ?></div>`
      
              to
      
                   <div id="PageBody">
                     <?php 
                    Gdn::Controller()->FireEvent('BeforePageFormatBody'); 
                     echo $FormatBody; ?>
      
                     </div>
                  </div>
      
      
      in you basicpage text box
      
      you could put 
      
      this is a test
      
      <COUNTDOWN>
      

    I'm sure there is a better way that is more flexible, if someone want to play around

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    peregrineperegrine MVP
    edited September 2013

    Perhaps @ShadowDare or @hgtonight have some better ideas.

    @ShadowDare - I just tried your basic pages app - pretty slick and easy to use.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    Many thanks peregrine! This really opens up the possibilities for me [and others].

    Now, time for a little code play :-)



    N-

  • Options

    Actually this may be better - undo the other changes I suggested.

    @Nouralis

     in the basicpages/views/page/index.php
    
        change 
        $Session = Gdn::Session();
        $Page = $this->Data('PageData');
    
        to
    
        $Session = Gdn::Session();
        $this->FireEvent('BeforePageFormatBody'); 
        $Page = $this->Data('PageData');
    

    in

    in classcountdown.plugin.php

    before line
    
        public function Base_AfterCommentFormat_Handler($Sender) {
        add these lines ---
    
    
        public function PageController_BeforePageFormatBody_Handler($Sender) {
            $TestBody = ($Sender->Data('PageData')->Body); 
            $Sender->Data('PageData')->Body = $this->DoReplacement($TestBody);
        }
    

    in your page body

            this is a test
        [COUNTDOWN]
        <br />
        hello
    

    and make sure this is checked

    x Disable automatic body formatting and allow raw HTML?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    hgtonighthgtonight ∞ · New Moderator

    You the man @peregrine!

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

Sign In or Register to comment.