Customer Portal

Get Involved. Join the Conversation.

Topic

    DustinTuft
    is there a widget to dispay a Standard TextAnswered
    Topic posted June 15, 2009 by DustinTuft Bronze Medal: 1,250+ Points, last edited October 29, 2011 
    1822 Views, 12 Comments
    Title:
    is there a widget to dispay a Standard Text
    Content:

    Is there a standard RNT widget to render a standard text to the screen? I am tring to change how we display the Notices section on our site. Want to be able to place this content in to a standard text that others could update as well, as it is now I have to redeploy the site to make a change here as it is hard HTML coded. I have looked at AnnouncementText, but I need to use this section for system notices for when we are expetion a site issue or a major service outage.

     

    Thanks

    Best Comment

    DustinTuft

    LOL was that a hint hint?

     

    well so I wrote this very simple widget, my SQL call is a bit bloated, but it worked, I feel RNT could sup it up a bit and add the base engine for the nice scripting that Standard Texts support (hint hint)..

     

    I did decide this was easer becasue we have two interfaces that are both really the same except one is SSL and one is non SSL (non SSL is connected to our Lithium forum, so we could avoid the security notices when authenicating)

     

    Widget Call:

     

    <rn:widget path="custom/pgpstandardtext" standardtextid="1" />

     

    View:

     

    <rn:meta controller_path="custom/pgpstandardtext" /><?=$standardtext?>

     

    Controller:

    <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class pgpstandardtext extends Widget { function pgpstandardtext() { parent::Widget(); $this->attrs['standardtextid'] = new Attribute(msg_get_rnw(RNW_FILE_NAME_LBL), 'STRING', msg_get_rnw(FILE_NAME_ANNOUNCEMENT_DISP_PATH_MSG), '0'); } function generateWidgetInformation() { $this->info['notes'] = msg_get_rnw(WIDGET_DISP_CONTENTS_HTML_FILE_MSG); } function getData($data) { $data['standardtext'] = ""; $pgp_SQL = "SELECT val from std_content where (sc_id = '" . $data['attrs']['standardtextid'] . "' )"; $pgp_sla = sql_prepare( $pgp_SQL ); sql_bind_col( $pgp_sla, 1, BIND_NTS, 4000 ); while ($iisrow = sql_fetch($pgp_sla)) { $data['standardtext'] = $iisrow[0]; } sql_free($pgp_sla); return $data; } }

     

    Comment

     

    • monique perkins

      No there isn't one.  You would have to make your own.

       

      The announcement text sees like it would work for you.  It was designed to be used as a way to update content on your site quickly without a redeploy.   You can have several different Announcement text widgets pointing to different html files. 

    • DustinTuft

      Humm I think I would still have to re-deploy to make a change in the HTML file hosted on CP right?

       

      Thanks for getting backto  me so quickly, any quick pointers on accessing DB objects such as the Standard Text?

    • Ernie Turner
      No, since the AnnouncementText widget pulls the HTML file from the /euf/assets directory, you do not have to deploy since those files are shared between development and production. Any changes you make to those files will immediately affect production.
    • DustinTuft

      That works, I am still in the process of replacing our static HTML with using the AnnouncementText widget, so that helps a great deal. So that will work for what I am doing. Althought having a widget that can pull from standard text would allow me to hand off this type of content magement to some one else with out exposing the web portal files.

       

      Thanks

    • Leif Wickland
      Dustin,

      I think you could write a widget which used
      $message = sql_get_str("SELECT val from std_content where sc_id = $someWidgetAttribute");
      
      to grab the value from the database.

      This seems like it could be a useful widget that would be widely useful to others if you posted it back here after you wrote it.

      Feel free to ask if you have more questions.
    • DustinTuft

      LOL was that a hint hint?

       

      well so I wrote this very simple widget, my SQL call is a bit bloated, but it worked, I feel RNT could sup it up a bit and add the base engine for the nice scripting that Standard Texts support (hint hint)..

       

      I did decide this was easer becasue we have two interfaces that are both really the same except one is SSL and one is non SSL (non SSL is connected to our Lithium forum, so we could avoid the security notices when authenicating)

       

      Widget Call:

       

      <rn:widget path="custom/pgpstandardtext" standardtextid="1" />

       

      View:

       

      <rn:meta controller_path="custom/pgpstandardtext" /><?=$standardtext?>

       

      Controller:

      <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class pgpstandardtext extends Widget { function pgpstandardtext() { parent::Widget(); $this->attrs['standardtextid'] = new Attribute(msg_get_rnw(RNW_FILE_NAME_LBL), 'STRING', msg_get_rnw(FILE_NAME_ANNOUNCEMENT_DISP_PATH_MSG), '0'); } function generateWidgetInformation() { $this->info['notes'] = msg_get_rnw(WIDGET_DISP_CONTENTS_HTML_FILE_MSG); } function getData($data) { $data['standardtext'] = ""; $pgp_SQL = "SELECT val from std_content where (sc_id = '" . $data['attrs']['standardtextid'] . "' )"; $pgp_sla = sql_prepare( $pgp_SQL ); sql_bind_col( $pgp_sla, 1, BIND_NTS, 4000 ); while ($iisrow = sql_fetch($pgp_sla)) { $data['standardtext'] = $iisrow[0]; } sql_free($pgp_sla); return $data; } }

       

    • Leif Wickland
      Dustin,

      Great job. Thanks for sharing that.

      Like you said, the getData() function could be a little tighter if you wrote it like this.

      $data['standardtext'] = sql_get_str("SELECT val from std_content where sc_id = {$data['attrs']['standardtextid']}");
      return $data;
    • DustinTuft
      I noticed you skipped right over that FMR :smileyhappy:
    • VMAGreg

      For those using Feb '09 (and maybe later?) you'll get an error with Lief's code as the sql_get_str function requires two parameters. This worked for me:

       

      $data['standardtext'] = sql_get_str("SELECT val from std_content where sc_id = {$data['attrs']['standardtextid']}", 255);return $data;

      Also, if you wanted the HTML value from the Standard Text instead, try:

       

       

      $data['standardtext'] = sql_get_str("SELECT html_val from std_content where sc_id = {$data['attrs']['standardtextid']}", 255);return $data;

      Thanks guys, this is a cool widget!!

    • Leif Wickland
      Greg,

      Thanks for noticing that mistake. I'm pretty sure all versions of sql_get_str() require two parameters. That should teach me to try code before posting it, but it won't.
    • January Fredericks
      Thank you for posting this! We've been wrestling with this for a while now, as our CS Mgmt team wants to be able to make these updates independant of the dev files. This works great!!!
    • Stuart Lipinski

      Just found this, had to say a big thanks. Perfect for allowing users who you don't want to give CP access to the ability to update a content pane on the CP.

      Fantastic!