The typical way to pass a query string to a link path, in the l() function, is to supply a 'query' array. However, there is no way to do so via theme_simple_dialog_link().

CommentFileSizeAuthor
#1 simple_dialog-1791940-1.patch902 bytespaulmckibben

Comments

paulmckibben’s picture

Title: Unable to pass a query string to add to the link path in theme_simple_dialog_link() » Unable to append a query string to the link path in theme_simple_dialog_link()
Status: Active » Needs review
StatusFileSize
new902 bytes

Please see attached patch that allows you to pass an additional ['link_options'] array in $args. Thanks!

Example: (results in some/drupal/path?myquery=value)

    $link_args = array (
      'text' => 'Link text',
      'path' => 'some/drupal/path',
      'title' => 'Dialog Title',
      'selector' => 'block-system-main',
      'class' => array(),
      'options' => array(
        'width' => 700,
      ),
      'link_options' => array (
        'query' => array('myquery' => $value),
      ),
    );
    print theme('simple_dialog_link', $link_args);
drclaw’s picture

Status: Needs review » Fixed

Hey, nice idea. Thanks for that patch! I had to modify it just a little bit though. The array merge was overwriting the required attributes (the ones assigned in the $link_options variable) if attributes were passed in the 'link_options' argument for the theme function. Instead, I merged the attributes first, then merged the link_options. Also, I added the link_options to the default variables in hook_theme. Additionally I found a bug where I was still keying the default variables in hook_theme as 'arguments'. I fixed that so now if you call theme('simple_dialog_link'...) and don't supply, for example, any classes, it won't give you an array index error. Lastly, I added a quick bit of documentation for the new theme function variable.

Anyway, Thanks again for the patch! I pushed a new release (7.x-1.7).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.