User login

Pass information from a URL into a Drupal page or form

The solutions are not Drupal-specific, should work in any PHP.

drupal pass url to form

arg(2) does it -- or arg(0) or arg(1) or whatever.

panels arguments title
Done. Note: Panels 2 will be able to have a title influenced by arguments without any need for this hack.

<pre>
function place_taxonomy_display_title() {
  if (arg(0) == 'place' && arg(1)) {
    // even though 99% of the time it will be only one
    $tids = arg(1);
    $title = '';
    $sep = '';   
    foreach (preg_split('/[ \+\,]/', $tids) AS $tid) {
      $term = taxonomy_get_term($tid);
      $title .= $sep . $term->name;
      $sep = ', ';
    }
    return '&lt;h2&gt;' . $title . '&lt;/h2&gt;';
  }
 
}

Still need to figure this out for a form, but it should be the same. Although in that case we're talking about a query string, post question mark. Probably is different...

Update: What about the true page title, in the browser bar?

Martijn's SEO recommendations

Leave the date out of the title. Title tag is important. Use pathauto to get nice url's :)

and question:

Hi Ben,

I read about your post with panels-title:
http://agaricdesign.com/note/pass-information-from-url-drupal-page-or-form
Are you sure Panels 2 will be able to have a title influenced by arguments?

I have not seen it yet. And am trying also to get the title nicely
shown...is not working without changing theme yet.
See my post: http://drupal.org/node/196603

Where do I need to put your function otherwise to get my panel showing the
arguments in the url?

Where my SEO-tips usefull?

Greetings,
Martijn

Haven't figured this out, actually-- drupal_set_title is not working on our place pages.

Martijn did it, but it's certainly a workaround:

I did a change in my page.tpl.php to get this working. It took me 10 hours
to find out everything, but it works. See:
www.gratis-informatie.nl/over/kerst/nederland

I did the following:

My panelname is "over".
The code in page.tpl.php:
is:
<?php
 if (arg(0) == 'over'){ $head_title = $title;}
 else
?>

<?php
 print  $head_title;
?>

And in my argument handling code I set:
-------
$tmpterms_0 = taxonomy_get_term_by_name(arg(1));
// array of term's objects by name (third argument from arguments)
$tmpterms_1 = taxonomy_get_term_by_name(arg(2));
drupal_set_html_head(''. $tmpterms_0[0]->name . ' ' .
$tmpterms_1[0]->name . '');
-------

First argument "kerst"
Second argument "nederland"
Will this work for you?

Hopefully it helps your great initiative!
I will be glad to be more of assistance from Holland? Do you have already a
participant from holland?

Greetings,
Martijn

Resolution

Searched words: 
PHP argument arg

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.