Customer Portal

Get Involved. Join the Conversation.

Topic

    MikeP
    Passing values to 'ask'Answered
    Topic posted October 7, 2008 by MikeP Gold Trophy: 10,000+ Points, last edited October 29, 2011 
    1545 Views, 3 Comments
    Title:
    Passing values to 'ask'
    Content:

    In 'Classic' ask.php you can pass (prepopulate) values for Product, Category, Subject, Question and custom fields.  How is that accomplished in CP?

     

    Mike

    Best Comment

    Ernie Turner

    Yes, it can be accomplished, but our standard widgets do not currently support this functionality. You would have to customize the Input widget and create customized URL parameters. So for example, in your custom Input widget, you could check for a 'cf12' parameter and set the value of that parameter to the value of the widget. Then when you create a link to that page, it would look like

     

    /app/ask/cf12/hello%20world

     

    You could make it dynamic in your custom widget by saying

     

    $value = getUrlParm("cf" . $data['attrs']['cf_id']);

    Comment

     

    • monique perkins

      We take the default value of a custom field if it exists, but currently we don't allow for a default value of a standard field.

       

      To get this functionality you can:

      1 - copy the input widget to a custom widget

       

      2 - add a default attribute

      $this->attrs['default'] = new Attribute('default', 'STRING', 'default to display if ther is no field or default value', '');

       

      3 - check the data['value'] and set it to the default - so before the data is returned on line 270 of the controller.  something like:

      $data['value'] = ($data['value']) ? $data['value'] :  $data['attrs']['default'];

       

       

    • MikeP

      Monique,

        I am not sure you understood my question.  Either that or I did not understand your answer.

       

       In classic I could formulate a URL to pass values to the ask page:

       

      ask.php?p_icf_51=hello%20world

       


      This would populate the custom field (id=51) with 'Hello World'.  You can likewise populate every other standard and custom field. 

       

      Can this be accomplised in CP?

       

      Mike

    • Ernie Turner

      Yes, it can be accomplished, but our standard widgets do not currently support this functionality. You would have to customize the Input widget and create customized URL parameters. So for example, in your custom Input widget, you could check for a 'cf12' parameter and set the value of that parameter to the value of the widget. Then when you create a link to that page, it would look like

       

      /app/ask/cf12/hello%20world

       

      You could make it dynamic in your custom widget by saying

       

      $value = getUrlParm("cf" . $data['attrs']['cf_id']);