Results 1 to 4 of 4

Thread: accordion - php panels

  1. #1
    Ext User
    Join Date
    Jul 2007
    Location
    Calgary, AB
    Posts
    10

    Default accordion - php panels

    Hello,

    I am trying to load php into the accordions. Basically I want the accordion panel header to auto generated from a database. I have everything setup, but my problem is the accordion.js file, this is the file that would need generate the dynamic headers, is there a way to create this with php?

    The code I have tried and it has failed is:

    PHP Code:
    // Ext Accordion Application

    Ext.BLANK_IMAGE_URL = '../extjs/resources/images/default/s.gif';

    Ext.onReady(function() {
      // create accordion
      var acc = new Ext.ux.Accordion('acc-ct', {
        fitHeight: true
      })

    <?PHP

    require("config.php");

    ?>

    <?php
      
      $result3 
    mysql_query("SELECT * FROM videos");
      
      while (
    $row3 mysql_fetch_array($result3)) {
      
      echo 
    "// create panel $row3[videoID]
      var panel
    $row3[videoID] = acc.add(new Ext.ux.InfoPanel('panel-$row3[videoID]', {
      }));"
    ;
      
      }
    ?>

    // end of file
    Probably failed because javascipt pages cannot handle PHP, but I'm not sure how to do this.

  2. #2
    Ext User
    Join Date
    Jul 2007
    Location
    Calgary, AB
    Posts
    10

    Default

    Nevermind, I have figured it out. I just put the code in the main page instead of having a .js include

    Here is the code:

    PHP Code:
    <script>
    // Ext Accordion Application

    Ext.BLANK_IMAGE_URL = '../extjs/resources/images/default/s.gif';

    Ext.onReady(function() {
      // create accordion
      var acc = new Ext.ux.Accordion('acc-ct', {
        fitHeight: true
      })

    <?php
      
      $result3 
    mysql_query("SELECT * FROM videos");
      
      while (
    $row3 mysql_fetch_array($result3)) {
      
      echo 
    "  // create panel $row3[videoID]
      var panel
    $row3[videoID] = acc.add(new Ext.ux.InfoPanel('panel-$row3[videoID]', {
      }));
      
      "
    ;
      
      }
    ?>
    });

    // end of file
    </script>

  3. #3
    Sencha Premium User
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    I don't really know PHP, but you'd want your php to configure stuff and then pass it off to your javascript, so for example, you'd want your php to produce:

    Ext.onReady(function()
    {
    MyObject.initialise(generatedData);
    }
    );

    And then have your javascript work through the generatedData to create your accordion.

  4. #4

    Default

    Quote Originally Posted by dillenger View Post
    Hello,

    I am trying to load php into the accordions. Basically I want the accordion panel header to auto generated from a database. I have everything setup, but my problem is the accordion.js file, this is the file that would need generate the dynamic headers, is there a way to create this with php?

    The code I have tried and it has failed is:

    PHP Code:
    // Ext Accordion Application

    Ext.BLANK_IMAGE_URL = '../extjs/resources/images/default/s.gif';

    Ext.onReady(function() {
      // create accordion
      var acc = new Ext.ux.Accordion('acc-ct', {
        fitHeight: true
      })

    <?PHP

    require("config.php");

    ?>

    <?php
      
      $result3 
    mysql_query("SELECT * FROM videos");
      
      while (
    $row3 mysql_fetch_array($result3)) {
      
      echo 
    "// create panel $row3[videoID]
      var panel
    $row3[videoID] = acc.add(new Ext.ux.InfoPanel('panel-$row3[videoID]', {
      }));"
    ;
      
      }
    ?>

    // end of file
    Probably failed because javascipt pages cannot handle PHP, but I'm not sure how to do this.
    You can rename your accordion.js file to accordion.js.php and then use any php code inside it!!

    Note: use this to include your js file into your HTML code:

    <script language="javascript" src="accordion.js.php"></script>

    Good Luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •