We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32963
    • 1,732 Posts
    Quote from: OpenGeek at Dec 17, 2005, 09:49 PM

    So widgets will not be persisted in the database?

    Widgets will be saved to the database as the are done today be it via Propel or DBAPI but they will not extend the Widgets table from the database.

    The Widget’s BaseWidget class will be separate from the Widgets table class used in Propel. Widgets for the most part are not executed from the database they are executed from a cached file.
      xWisdom
      www.xwisdomhtml.com
      The fear of the Lord is the beginning of wisdom:
      MODx Co-Founder - Create and do more with less.
      • 22303 MODX Staff
      • 10,725 Posts
      Why would you instantiate a totally different class to get the data from a Widget object, regardless if it is persisted in a DB or in a file representation of the object? Shouldn’t this just be a behavioral extension (e.g. a method) on the Widget object?

      e.g.
      $widget= $modx->getWidgetByName('MyWidget');
      $widget->renderOutput();


      The widget knows what class is it is and can instantiate the proper class extension to override the behavior of the renderOutput() method?
        • 32963
        • 1,732 Posts
        I’ve not reach that section of the code as yet so I’ll reserve all further comments on it until I’m there.

        I for one like the $cms->getWidgetByName() function although I was more thinking of a $cms->getWidgetObject() function.

        There will also be a $cms->getWidgetById() function that will be used to return an instance of the Widget. For example:

        Consider this Button Widget:
        [[Button? &_id=`btnSave` &text=`Save`]]
        [[Button? &_id=`btnCancel` &text=`Cancel`]]

        In your code you’ll be able to get a reference to the btnCancel button by using:

        $btn = $cms->getWidgetById('btnCancel');
        $btn->setProp('style','border:1px solid #c0c0c0');

          xWisdom
          www.xwisdomhtml.com
          The fear of the Lord is the beginning of wisdom:
          MODx Co-Founder - Create and do more with less.