Thread

Plugin: GET/POST Parameters

September 17, 2009 10:26pm

Subscribe [10]
  • #1 / Sep 17, 2009 10:26pm

    litzinger's avatar

    litzinger

    614 posts

    A simple plugin to print out any get or post params from a form.

    Print a single parameter: {exp:parameters:get name="job_id"} or {exp:parameters:post name="job_id"}

    Print multiple parameters:

    {exp:parameters}
        {get_job_id}
        {get_foobar}
    {/exp:parameters}

    Loop through a parameter that is an array:

    {exp:parameters}
        <ul>
        {post_foobar}
            <li>{key} {value}</li>
        {/post_foobar}
        </ul>
    {/exp:parameters}

    Biggest difference is the only way to get multiple parameters is to use the tag pair. You can add parse=”inwards” to the tag par if you have trouble with the parsing order.

    There is a parameter “flatten_arrays=’yes’”, which will take something like $_POST[‘key’] => ‘value’ and return the following: post_key_value. What purpose that might have to someone, I don’t know, but I added it when I was experimenting/having trouble with a form.

    Latest version is 1.3

  • #2 / Sep 29, 2009 7:45am

    Mark Croxton's avatar

    Mark Croxton

    318 posts

    Thanks for this, I found it very useful.

  • #3 / Oct 01, 2009 11:13am

    litzinger's avatar

    litzinger

    614 posts

    Edited

  • #4 / Oct 02, 2009 10:28am

    litzinger's avatar

    litzinger

    614 posts

    Updated the plugin to 1.2. Separated the things out into different methods to avoid parsing issues when using the single variable, and variable pair in the same template. Download latest at URL in original post.

  • #5 / Oct 07, 2009 11:09pm

    Aniden

    4 posts

    Hi. I am unable to get this plugin to work (Exp 1.6.8 on plugin version 1.2). I get a “Notice: Undefined variable: v in xxxx/www/public_html/admin/plugins/pi.parameters.php on line 66” error.

    Test commands used are:

    {exp:parameters:get name="screen_name"}
    {exp:parameters:get name="test"}

    Each was presented with a get query of the following, respectively:

    http://localhost/community/members/?screen_name=jsmith
    http://localhost/community/members/?screen_name=test

    David

  • #6 / Oct 08, 2009 10:11am

    litzinger's avatar

    litzinger

    614 posts

    Yep, there was an undefined variable. Try downloading it again, or change line 65 from this:

    if($name and $IN->GBL($v, 'GET'))

    to this:

    if($name and $IN->GBL($name, 'GET'))
  • #7 / Oct 28, 2009 11:33pm

    Nick Foxall's avatar

    Nick Foxall

    189 posts

    Can you post some sample code to show how this plugin actually works WITHIN a typical form setup / tags? I’ve been mucking around with this and I can’t get it work at all.

    Also, could this plugin be used to pass a parameter from one page to another via the URL?

    Cheers, Nik

  • #8 / Nov 26, 2009 9:28am

    portnull's avatar

    portnull

    8 posts

    hello, nice plugin, but shouldn’t this work?

    http://www.domain.com/template/article/?var=test

    this returns nothing in my templates. however:

    http://www.domain.com/template/article/&var=test

    does. is there a way to GET vars that are added to the url by questionmark ?

  • #9 / Dec 30, 2009 3:57pm

    Brad Morse's avatar

    Brad Morse

    428 posts

    I am trying to use this in the forgot password form.

    So I put this within the form

    <input type="hidden" name="forgot_password_variable" value="true">
    {exp:parameters post="forgot_password_variable"}

    Then in the specialty template: user messages, I put this code in to detect it

    {exp:parameters:get name="forgot_password_variable"}

    it does not recognize it at all. From the previous responses, it was not clear how you actually implement this with a form.

    Any help is appreciated.

  • #10 / Jan 19, 2010 10:56pm

    iain's avatar

    iain

    317 posts

    Seems like Brian’s site is down, and going through google cache reveals the file doesn’t exist on the server…

    Would be really useful to have this plugin just now 😊

  • #11 / Mar 01, 2010 3:45pm

    iDVB's avatar

    iDVB

    56 posts

    Can’t seem to get his working with the {exp:query}

    Eg.

    {exp:parameters}
    {get_search_input}
    {exp:query sql="SELECT *
                    FROM exp_weblog_titles
                    WHERE weblog_id = 2
                    AND title LIKE '{get_search_input}'"}
    
    <ul>
    {exp:weblog:entries entry_id="{entry_id}"}
        <li>{title}</li>
    {/exp:weblog:entries}
    </ul>
    
    {/exp:query}
    {/exp:parameters}

    I’ve tried this:

    AND title LIKE '%{get_search_input}%'"}

    this:

    AND title LIKE '%"{get_search_input}"%'"}

    and this:

    AND title LIKE '%%{get_search_input}%%'"}

    Still can get the nesting to work.

    Any ideas?

  • #12 / Mar 01, 2010 5:50pm

    litzinger's avatar

    litzinger

    614 posts

    Try adding parse=”inward” to the parameters tag.

  • #13 / Mar 01, 2010 11:31pm

    iDVB's avatar

    iDVB

    56 posts

    Worked like a charm! thanks a ton litzinger!

  • #14 / Jun 03, 2010 1:33pm

    Brad Morse's avatar

    Brad Morse

    428 posts

    I am unsure on how this works.

    I have a SAEF, that returns to /post/thankyou

    {exp:weblog:entry_form 
        weblog="ajax_form" 
        return="/post/thankyou" 
        status="Open"
    }

    So I put {exp:parameters:post name="title"} within that template, then within the /post/thankyou template I’ve tried the following to get the title value this plugin is suppose to post

    {exp:parameters:get name="title"}

    and

    <?php print $_GET['title']; ?>

    neither gets the posted variable title that the plugin posts

  • #15 / Jun 09, 2010 5:56pm

    Studio Hert

    36 posts

    Same problem here. Plugin doesn’t seem to work with SAEF submitting?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases