Announcement

Collapse
No announcement yet.

PHP Function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    PHP Function

    Hi all,

    I'm sure this has been posted somewhere but i can't find the blasted thing...

    I want to use
    Code:
    <actinic:block php="true">echo date("F");</actinic:block>
    but obviously actinic parses the php itself so i have to upload for the date to update which pretty much defeats the object of doing it!

    I think there's a way of enclosing it in another function but i can't work it out.

    Thanks
    http://www.itwiz.co.uk

    http://www.AntiV.net - The Discount Antivirus Store

    #2
    try this thread

    Comment


      #3
      thanks 8910
      http://www.itwiz.co.uk

      http://www.AntiV.net - The Discount Antivirus Store

      Comment


        #4
        ok, tied it but doesn't seem to be working.
        i'm using...

        Code:
         
        <actinic:block php="true">
        if (!function_exists('myFunc')) 
        { 
         function myFunc($variable) 
        {    
        echo date("F") ; 
        }    
        } 
         </actinic:block>
        but the month doesn't show up
        http://www.itwiz.co.uk

        http://www.AntiV.net - The Discount Antivirus Store

        Comment


          #5
          Put a small PHP routıne on your server (todaysdate.php) that returns a line of JavaScript containing a statement like

          document.write('todays date');

          Then in your layout use

          <script type="text/javascript" src="todaysdate.php"></script>

          Note untested and may be buggy due to being typed on a Turkish keyboard.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            Thanks for that Norman,

            Im getting somewhere.
            in my month.php file i have
            Code:
             
            document.write('echo date("F");');
            and then
            Code:
            <script type="text/javascript" src="month.php"></script>
            outputs "echo date("F");" instead of the Month.
            http://www.itwiz.co.uk

            http://www.AntiV.net - The Discount Antivirus Store

            Comment


              #7
              Edited for a better answer.

              <?
              echo date("F");
              ?>


              Mike

              OK. I might have missed what Norman was suggesting. Try this:

              Code:
              document.write('<?echo date("F");?>');
              i.e. It's probably the missing <? ?> that you need so the server will parse the php code.

              Mike
              -----------------------------------------

              First Tackle - Fly Fishing and Game Angling

              -----------------------------------------

              Comment


                #8
                Hi, Thanks

                tried that but now i get output on the page...

                unexpected < on line 1
                http://www.itwiz.co.uk

                http://www.AntiV.net - The Discount Antivirus Store

                Comment


                  #9
                  PHP Code:
                  <? echo

                  __^
                  there should be a space here.

                  Comment


                    #10
                    thanks gabe,

                    still get the same error though.
                    http://www.itwiz.co.uk

                    http://www.AntiV.net - The Discount Antivirus Store

                    Comment


                      #11
                      Matt - may be worth posting what you have now for someone to take another look.


                      Bikster
                      SellerDeck Designs and Responsive Themes

                      Comment


                        #12
                        Matt

                        You want your PHP to return a line of valid JavaScript. E.g.

                        document.write('Friday 4th July 2008');

                        I'll leave it to you to work that out.
                        Norman - www.drillpine.biz
                        Edinburgh, U K / Bitez, Turkey

                        Comment


                          #13
                          Ok, where i want the date to appear I have...

                          Code:
                          !!<<actinic:block php="true"><script type="text/javascript" src="month.php"></script></actinic:block>>!!
                          and in 'month.php' I have...

                          Code:
                          document.write('<? echo date("F"); ?>');
                          i tried
                          Code:
                          document.write('<?php echo date("F"); ?>');
                          too but that still produces the same error.

                          Instead i have put
                          Code:
                          <?php echo date("F"); ?>
                          in month.php
                          and done
                          Code:
                          !!<<actinic:block php="true">include 'month1.php';</actinic:block>>!!
                          in a fragment which i believe will update as actinic will not parse month.php but the server should. Is this correct?

                          Norman - tried really hard to understand where i was going wrong. looked at both php and javascript syntax guides and i can't see it.

                          Thanks all for your patience
                          http://www.itwiz.co.uk

                          http://www.AntiV.net - The Discount Antivirus Store

                          Comment


                            #14
                            ok thinkingon it - if it was as simple as a php include, someone would have just said use that, also, this works offline, which means actinic is parsing it - damn.

                            If anyone can offer some more guidance i'd appreciate it. im happy to work for the answer, but i seem to need a little more than what Normans given.

                            cheers
                            http://www.itwiz.co.uk

                            http://www.AntiV.net - The Discount Antivirus Store

                            Comment


                              #15
                              Matt,

                              I knew it would come down to me doing it for you!

                              The line
                              Code:
                              !!<<actinic:block php="true"><script type="text/javascript" src="month.php"></script></actinic:block>>!!
                              Is wrong as you're trying to call PHP when it isn't needed.

                              Use (if in a Layout)
                              Code:
                              <script type="text/javascript" src="month.php"></script>
                              If you're putting this in a product description use
                              Code:
                              !!<<script type="text/javascript" src="month.php"></script>>!!
                              Norman - www.drillpine.biz
                              Edinburgh, U K / Bitez, Turkey

                              Comment

                              Working...
                              X