Loading ...
Sorry, an error occurred while loading the content.

YUI Datatable, MVC with zend and getting data client side from PHP server side

Expand Messages
  • Holly
    I admit i m a newbie. I have used MS aspx (.net) for too long and i am now converting to a better world. I have done alot of reading, but there is one link i
    Message 1 of 6 , Apr 28, 2009
    • 0 Attachment
      I admit i'm a newbie. I have used MS aspx (.net) for too long and i am now converting to a better world. I have done alot of reading, but there is one link i am missing...

      I am using zend framework to implement an MVC setup with page controllers that all requests are directed thru. I am pulling data from a MySQL database and i have come up with classes that pull the data into nice objects using PHP. But i'm stuck on how to get my objects in PHP on the server into my YUI datatable on the client side javascript. I see options using calls to pages, but my data is in an object. I see how i could use php on the page to render the data, but I want to use the YUI objects instead of reinventing the wheel. I'm sure i'm missing something.

      Any advice on how to do this? or maybe I need to just change my tactic?

      Thanks in advance for your help in making me a convert!

      hs
    • theblargoner
      Hi, If I m understanding your situation right, you re going to need to somehow translate the data from the PHP objects into a form that can be used by the YUI
      Message 2 of 6 , Apr 28, 2009
      • 0 Attachment
        Hi,
        If I'm understanding your situation right, you're going to need to somehow translate the data from the PHP objects into a form that can be used by the YUI DataSource object. The DataSource accepts a variety of input formats (HTML table, XML, JS array, JSON, etc.). But since your PHP objects are server-side and the YUI objects are client-side, some translation will be necessary.

        I'm not clear why outputting the data to an HTML table, then creating the DataSource/DataTable from this would not work in your case, but if you want to avoid that another alternative might be creating a different view and serializing the PHP object(s) to appropriate XML or JSON, and pulling that directly through JS.

        John

        --- In ydn-javascript@yahoogroups.com, "Holly" <hstarli@...> wrote:
        >
        > I admit i'm a newbie. I have used MS aspx (.net) for too long and i am now converting to a better world. I have done alot of reading, but there is one link i am missing...
        >
        > I am using zend framework to implement an MVC setup with page controllers that all requests are directed thru. I am pulling data from a MySQL database and i have come up with classes that pull the data into nice objects using PHP. But i'm stuck on how to get my objects in PHP on the server into my YUI datatable on the client side javascript. I see options using calls to pages, but my data is in an object. I see how i could use php on the page to render the data, but I want to use the YUI objects instead of reinventing the wheel. I'm sure i'm missing something.
        >
        > Any advice on how to do this? or maybe I need to just change my tactic?
        >
        > Thanks in advance for your help in making me a convert!
        >
        > hs
        >
      • Holly
        i realize im not real clear here but i ll try to explain more. in .net terms i would call it a class on the server side that i can use for any and all of my
        Message 3 of 6 , Apr 28, 2009
        • 0 Attachment
          i realize im not real clear here but i'll try to explain more.

          in .net terms i would call it a class on the server side that i can use for any and all of my tables that returns my data as an object(?) - complete with public characteristics etc. so in php, $this->view->tableobject=$this->tableobject - then i could insert the data in the html using php <? php $this->tableobject ?>

          what i dont want to do is now create a page for every different table or view of the data and a controller for each along with model, view etc. this seems to defeat the idea. isnt there some way to pass this object/class with its characteristics to the yui datatable? technically, i have created an array of objects since i am looking to use a datatable - and this is what i want to pass to the datatable.

          thanks for your suggestions.
          h


          --- In ydn-javascript@yahoogroups.com, "theblargoner" <theblargoner@...> wrote:
          >
          > Hi,
          > If I'm understanding your situation right, you're going to need to somehow translate the data from the PHP objects into a form that can be used by the YUI DataSource object. The DataSource accepts a variety of input formats (HTML table, XML, JS array, JSON, etc.). But since your PHP objects are server-side and the YUI objects are client-side, some translation will be necessary.
          >
          > I'm not clear why outputting the data to an HTML table, then creating the DataSource/DataTable from this would not work in your case, but if you want to avoid that another alternative might be creating a different view and serializing the PHP object(s) to appropriate XML or JSON, and pulling that directly through JS.
          >
          > John
          >
          > --- In ydn-javascript@yahoogroups.com, "Holly" <hstarli@> wrote:
          > >
          > > I admit i'm a newbie. I have used MS aspx (.net) for too long and i am now converting to a better world. I have done alot of reading, but there is one link i am missing...
          > >
          > > I am using zend framework to implement an MVC setup with page controllers that all requests are directed thru. I am pulling data from a MySQL database and i have come up with classes that pull the data into nice objects using PHP. But i'm stuck on how to get my objects in PHP on the server into my YUI datatable on the client side javascript. I see options using calls to pages, but my data is in an object. I see how i could use php on the page to render the data, but I want to use the YUI objects instead of reinventing the wheel. I'm sure i'm missing something.
          > >
          > > Any advice on how to do this? or maybe I need to just change my tactic?
          > >
          > > Thanks in advance for your help in making me a convert!
          > >
          > > hs
          > >
          >
        • Satyam
          This article might help a little: http://satyam.com.ar/yui/#phpjson The code loops through an SQL query to generate a JSON return, you would loop through an
          Message 4 of 6 , Apr 29, 2009
          • 0 Attachment
            This article might help a little:

            http://satyam.com.ar/yui/#phpjson

            The code loops through an SQL query to generate a JSON return, you would
            loop through an object of your own. It also shows how to dispatch
            different functions according to URL arguments, how to wrap the reply in
            a proper envelope and how to handle PHP errors so they are sent to the
            browser as a JSON reply, not a human readable HTML page.

            Satyam


            Holly escribió:
            > i realize im not real clear here but i'll try to explain more.
            >
            > in .net terms i would call it a class on the server side that i can use for any and all of my tables that returns my data as an object(?) - complete with public characteristics etc. so in php, $this->view->tableobject=$this->tableobject - then i could insert the data in the html using php <? php $this->tableobject ?>
            >
            > what i dont want to do is now create a page for every different table or view of the data and a controller for each along with model, view etc. this seems to defeat the idea. isnt there some way to pass this object/class with its characteristics to the yui datatable? technically, i have created an array of objects since i am looking to use a datatable - and this is what i want to pass to the datatable.
            >
            > thanks for your suggestions.
            > h
            >
            >
            > --- In ydn-javascript@yahoogroups.com, "theblargoner" <theblargoner@...> wrote:
            >
            >> Hi,
            >> If I'm understanding your situation right, you're going to need to somehow translate the data from the PHP objects into a form that can be used by the YUI DataSource object. The DataSource accepts a variety of input formats (HTML table, XML, JS array, JSON, etc.). But since your PHP objects are server-side and the YUI objects are client-side, some translation will be necessary.
            >>
            >> I'm not clear why outputting the data to an HTML table, then creating the DataSource/DataTable from this would not work in your case, but if you want to avoid that another alternative might be creating a different view and serializing the PHP object(s) to appropriate XML or JSON, and pulling that directly through JS.
            >>
            >> John
            >>
            >> --- In ydn-javascript@yahoogroups.com, "Holly" <hstarli@> wrote:
            >>
            >>> I admit i'm a newbie. I have used MS aspx (.net) for too long and i am now converting to a better world. I have done alot of reading, but there is one link i am missing...
            >>>
            >>> I am using zend framework to implement an MVC setup with page controllers that all requests are directed thru. I am pulling data from a MySQL database and i have come up with classes that pull the data into nice objects using PHP. But i'm stuck on how to get my objects in PHP on the server into my YUI datatable on the client side javascript. I see options using calls to pages, but my data is in an object. I see how i could use php on the page to render the data, but I want to use the YUI objects instead of reinventing the wheel. I'm sure i'm missing something.
            >>>
            >>> Any advice on how to do this? or maybe I need to just change my tactic?
            >>>
            >>> Thanks in advance for your help in making me a convert!
            >>>
            >>> hs
            >>>
            >>>
            >
            >
            >
            >
            > ------------------------------------
            >
            > Yahoo! Groups Links
            >
            >
            >
            > ------------------------------------------------------------------------
            >
            >
            > No virus found in this incoming message.
            > Checked by AVG - www.avg.com
            > Version: 8.5.287 / Virus Database: 270.12.6/2084 - Release Date: 04/28/09 06:15:00
            >
            >
          • Holly
            YES!!!!!!! I skimmed thru the article and that looks exactly like what i was looking for! i knew there had to be a way to handle this and you have definitely
            Message 5 of 6 , Apr 29, 2009
            • 0 Attachment
              YES!!!!!!! I skimmed thru the article and that looks exactly like what i was looking for! i knew there had to be a way to handle this and you have definitely gotten me over my block and moving on to new ideas.

              HUGE thanks!

              h



              --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
              >
              > This article might help a little:
              >
              > http://satyam.com.ar/yui/#phpjson
              >
              > The code loops through an SQL query to generate a JSON return, you would
              > loop through an object of your own. It also shows how to dispatch
              > different functions according to URL arguments, how to wrap the reply in
              > a proper envelope and how to handle PHP errors so they are sent to the
              > browser as a JSON reply, not a human readable HTML page.
              >
              > Satyam
              >
              >
              > Holly escribió:
              > > i realize im not real clear here but i'll try to explain more.
              > >
              > > in .net terms i would call it a class on the server side that i can use for any and all of my tables that returns my data as an object(?) - complete with public characteristics etc. so in php, $this->view->tableobject=$this->tableobject - then i could insert the data in the html using php <? php $this->tableobject ?>
              > >
              > > what i dont want to do is now create a page for every different table or view of the data and a controller for each along with model, view etc. this seems to defeat the idea. isnt there some way to pass this object/class with its characteristics to the yui datatable? technically, i have created an array of objects since i am looking to use a datatable - and this is what i want to pass to the datatable.
              > >
              > > thanks for your suggestions.
              > > h
              > >
              > >
              > > --- In ydn-javascript@yahoogroups.com, "theblargoner" <theblargoner@> wrote:
              > >
              > >> Hi,
              > >> If I'm understanding your situation right, you're going to need to somehow translate the data from the PHP objects into a form that can be used by the YUI DataSource object. The DataSource accepts a variety of input formats (HTML table, XML, JS array, JSON, etc.). But since your PHP objects are server-side and the YUI objects are client-side, some translation will be necessary.
              > >>
              > >> I'm not clear why outputting the data to an HTML table, then creating the DataSource/DataTable from this would not work in your case, but if you want to avoid that another alternative might be creating a different view and serializing the PHP object(s) to appropriate XML or JSON, and pulling that directly through JS.
              > >>
              > >> John
              > >>
              > >> --- In ydn-javascript@yahoogroups.com, "Holly" <hstarli@> wrote:
              > >>
              > >>> I admit i'm a newbie. I have used MS aspx (.net) for too long and i am now converting to a better world. I have done alot of reading, but there is one link i am missing...
              > >>>
              > >>> I am using zend framework to implement an MVC setup with page controllers that all requests are directed thru. I am pulling data from a MySQL database and i have come up with classes that pull the data into nice objects using PHP. But i'm stuck on how to get my objects in PHP on the server into my YUI datatable on the client side javascript. I see options using calls to pages, but my data is in an object. I see how i could use php on the page to render the data, but I want to use the YUI objects instead of reinventing the wheel. I'm sure i'm missing something.
              > >>>
              > >>> Any advice on how to do this? or maybe I need to just change my tactic?
              > >>>
              > >>> Thanks in advance for your help in making me a convert!
              > >>>
              > >>> hs
              > >>>
              > >>>
              > >
              > >
              > >
              > >
              > > ------------------------------------
              > >
              > > Yahoo! Groups Links
              > >
              > >
              > >
              > > ------------------------------------------------------------------------
              > >
              > >
              > > No virus found in this incoming message.
              > > Checked by AVG - www.avg.com
              > > Version: 8.5.287 / Virus Database: 270.12.6/2084 - Release Date: 04/28/09 06:15:00
              > >
              > >
              >
            • mattatlamplight
              Hi, I m in a similar situation with Zend MVC and trying to integrate a bit with YUI. I ve written some classes that start to do this: - an autocomplete form
              Message 6 of 6 , Apr 30, 2009
              • 0 Attachment
                Hi,

                I'm in a similar situation with Zend MVC and trying to integrate a bit with YUI. I've written some classes that start to do this:
                - an autocomplete form element extending Zend_Form_Element_Text
                - a datatable that takes a Zend_Rowset or array of data from the db, renders an html table, and puts the javascript in the Zend script view helpers. ( I prefer the html as the datasource for progressive enhancement, although I've had to do some extra work to get pagination etc working - harder with HTML datasource).
                - a rte text editor form element extending Zend_Form_Element_Textarea

                At the moment they're quite messy - I've been learning YUI and Zend as I go, but I'd love a Zend_Yui_ component. I'd be quite happy to share if you'd like to see what I've got, but it won't be nearly as clear and nice as satyam's stuff.

                Is there anyone else around using Zend Framework and YUI?

                Cheers

                Matt
              Your message has been successfully submitted and would be delivered to recipients shortly.