Announcement

Collapse
No announcement yet.

Running PHP code in Actinic

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

    Running PHP code in Actinic

    Hi,

    First up, I am unfamiliar with PHP at any level.

    I use a javascript & CSS menu that extracts it's data from Act_section_tree.js. The problem is Actinic generates links that end with &NOLOGIN=1 which is interpreted differently by IE & FF. (IE works fine, FF reads it as consecutive ampersand and displays a login page).

    So I've tried adding a small bit of PHP to the end of my layouts that opens Act_section_tree.js and replaces all instances of & with &.

    My attempt at PHP (don't laugh too much - I know it is convoluted)

    PHP Code:
    <?php 
    $first 
    '&amp;';
    $second '&';
    $myFile "Act_section_tree.js";
    $fr fopen($myFile'r');
    $data fread($frfilesize($myFile));
    $filtered str_replace($first$second$data);
    fclose($fr);
    $fw fopen($myFile'w');
    fwrite($fw$filtered);
    fclose($fw);
    ?>
    If I save this as a .php file and upload it to the acatalog directory it works. It rewrites Act_section_tree.js successfully.

    If I paste it into the various layouts in Actinic it doesn't work. My questions are:

    1> Could this work? I'm not sure how I make the PHP run and rewrite the file right before it is uploaded.
    2> I was using echo to output the results to screen but couldn't get Actininc to display the correct results because I couldn't get it to take the $first & $second variables literally. Actinic highlights them as HTML in the code view so $first = & instead of &amp;. Is there some special escape character to do this?
    3> Lastly, am I wasting my time and is there a better/easier way to generate FF friendly links in the Act_section_tree.js file?

    Thanks in advance,

    #2
    first of all, i have to point out, that the sectiontree is very bad, seo wise, so i help you with the full knowledge that it wont be good for you.

    Actinic V8 includes some navigation functions. are these insufficient?

    1> 'nic would need you to do it manually, but you do know that actinic supports php in the templates?

    2 > i dont quite understand what you're up to here. are you including the file as js, or are you yting to write it as html inot the page?

    3 > simply dont use that js file. V8 has plenty of ways to get what you're looking for.

    Comment


      #3
      also:
      PHP Code:
      file_put_content("Act_section_tree.js",str_replace("&amp;","&",file_get_contents("Act_section_tree.js"))); 

      Comment


        #4
        Rewriting Act_section_tree.js

        Thanks for the reply Gabe,

        I like the concise look of the code you posted but I get a parse error when I try to use file_put_contents.

        Not sure if this is true but I thought Actinic's PHP version was 4.3 and according to PHP.net the file_put_contents command was introduced in 5. Does that sound right?

        1> Yeah, when I place the code in the templates it seems to have no effect on the js. I'm not sure if it runs before or after Actinic generates the file. Does anyone know when the js file is updated?

        2> I was just trying to display the results in the HTML to see if it worked. I was being lazy as I didn't want to keep opening the js file and see if it worked.

        3> I was hoping that wasn't case. We've been using this file since 7 had thrown a dit of dosh at developing a menu add on for Actinic.

        Comment


          #5
          I use a javascript & CSS menu that extracts it's data from Act_section_tree.js. The problem is Actinic generates links that end with &amp;NOLOGIN=1 which is interpreted differently by IE & FF. (IE works fine, FF reads it as consecutive ampersand and displays a login page).
          If you have JavaScript that's processing the Section Tree structure then why not simply add a line to your JavaScript to replace (in the .sURL field) the &amp; with the & that your code needs.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            Originally posted by 1stDuncan
            Not sure if this is true but I thought Actinic's PHP version was 4.3 and according to PHP.net the file_put_contents command was introduced in 5. Does that sound right?
            I did not know you were processing this inside Actinic itself, I thought it was a server side thing you were doing, sorry.

            I say this becasue in your initial example, your php is enclosed in the questionbraces. actninc does not do this, standalone php does.

            Comment

            Working...
            X