Customer Portal

Get Involved. Join the Conversation.

Topic

    Shiloh Madsen
    URL "building" widget neededAnswered
    Topic posted October 8, 2008 by Shiloh MadsenBronze Trophy: 5,000+ Points, last edited October 29, 2011 
    1319 Views, 3 Comments
    Title:
    URL "building" widget needed
    Content:

    Ok, so this looks like my first real need to get my hands dirty developing a ground up widget and I need a little feedback on how to go about it. Heres the situation:

     

    Our CMS will have need to call RNT pages and display things based upon variables. On the old implementaion we have something called integration.php which does this job. Essentially, here is what the code does:

     

    1: Recieves Action, Country Code, Language, product, keyword and category as Passed variables

     

    2: Based upon the passed language variable, it selects an interface (I.E. Language=EN => create $url of https://motorola-global-en-usa.custhelp.com).

     

    3: Based upon the action variable, it will set the "page" displayed (I.E. action=ask => append $url with /ask/

     

    4: If the action is faq search, the integration widget will have to read a plain text product name, such as MotoRazr v9 and map that to a product id in the database, likewise with passed category data.

     

    5: Then the integration page will append the $url with the product/category data (I.E. c/####,###,### or p/##,####,####

     

    6: Once this $url is built, it needs to be populated to the address bar and loaded

     

    So, my initial questions on approaching this problem revolve around getting data out of the database to compare against my passed variables. Where in the documentation can I read up on this process? I assume this logic will go in the model.php part of the code. Is this correct? Also, what would the view be for a page such as this? We aren't actually dispalying any data using this...simply building a url based upon a number of passed parameters.  

    Best Comment

    monique perkins

    I'm not quite sure I know what you are trying to do - but I'll give this a try:

     

    You want to take parameters from the url.  Based on those and a query(ies) you want to build a url and redirect to it.  

     

    1 - Make a widget with a blank view and reference your widget controller.  Put this widget on your page that you will initially hit with the url.

    2 -  In the widget controller get the url parameters and pass them into the model.  Look at the user conference code posed by Chris in the form.  In the zip file there is RegistrationWidget - there is code samples there to take url parms and pass them to the model

    3 - build a model function that takes these parms, makes whatever queries you need, and creates the url

    4 - do a redirect to the page - either from the widget controller (I *think* it can be done there) - or create javascript on the view/logic that  does the window.location redirect.

    Comment

     

    • monique perkins

      I'm not quite sure I know what you are trying to do - but I'll give this a try:

       

      You want to take parameters from the url.  Based on those and a query(ies) you want to build a url and redirect to it.  

       

      1 - Make a widget with a blank view and reference your widget controller.  Put this widget on your page that you will initially hit with the url.

      2 -  In the widget controller get the url parameters and pass them into the model.  Look at the user conference code posed by Chris in the form.  In the zip file there is RegistrationWidget - there is code samples there to take url parms and pass them to the model

      3 - build a model function that takes these parms, makes whatever queries you need, and creates the url

      4 - do a redirect to the page - either from the widget controller (I *think* it can be done there) - or create javascript on the view/logic that  does the window.location redirect.

    • Shiloh Madsen

      Thanks Monique. Would the active bit of code from taking post variables and using them within the widget be this one?:

       

      $term = $this->input->post('term'); 

    • monique perkins

      Yes - it will return null if the url parameter doesn't exist. 

       

      To get it into the view you will then need to put it in the data array

      $data['js']['term'] = $term;

      That will make it available in the view (as $js['term'] ) or in the javascript (as data.js.term)

       

      also  - In the documentation in the file exchange there are some api "java doc" style documentation of all the php and javascript functions and classes we have written that are available for use.