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 '<h2>' . $title . '</h2>';
}
}
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/196603Where 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/nederlandI 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
Comments
Post new comment