no solutions for this?? I've tried everything I can think of...escaping the characters, wrapping them in all sorts of other characters, but no luck. ----- Original Message ----- From: Neil Coghlan To: support@drupal.org Sent: Thursday, April 22, 2010 12:32 AM Subject: slight problem with encoding
I have the following php snippet giving me a list of taxonomy terms for a certain vocab and certain content type.
<?php $vid = 4; $items = array(); $type = manager; $terms = taxonomy_get_tree($vid); foreach ( $terms as $term ) { $count = db_result(db_query("SELECT COUNT(term_node.nid) FROM {term_node} JOIN {node} ON node.nid = term_node.nid WHERE node.type = '%s' AND tid = %d", $type, $term->tid)); $items[] = l($term->name, "personnel-search?type=$term->tid") . " ($count)"; } if ( count($items) ) { print theme('item_list', $items);} ?>
the problem is in the bolded line, specifically the question mark and equal sign. I get a taxonomy list like this:
retail (3) accounts (2) IT (1)
when I hover over these, the links look perfect down in the status bar, but when I click on them, they come out in the URL bar as such:
...personnel-search%3Ftype%3D25
and thus give me a 404. Is there an easy way of encoding it right?
thanks
Neil
Have you tried putting the curly braces around the variable call?
“personnel-search?type={$term->tid}”
http://php.net/manual/en/language.types.string.php, scroll down to Variable Parsing.
Jason
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Neil Coghlan Sent: Thursday, April 22, 2010 8:18 AM To: support@drupal.org Subject: Re: [support] slight problem with encoding
no solutions for this?? I've tried everything I can think of...escaping the characters, wrapping them in all sorts of other characters, but no luck.
----- Original Message -----
From: Neil Coghlan mailto:neil@esl-lounge.com
To: support@drupal.org
Sent: Thursday, April 22, 2010 12:32 AM
Subject: slight problem with encoding
I have the following php snippet giving me a list of taxonomy terms for a certain vocab and certain content type.
<?php $vid = 4; $items = array(); $type = manager; $terms = taxonomy_get_tree($vid); foreach ( $terms as $term ) { $count = db_result(db_query("SELECT COUNT(term_node.nid) FROM {term_node} JOIN {node} ON node.nid = term_node.nid WHERE node.type = '%s' AND tid = %d", $type, $term->tid)); $items[] = l($term->name, "personnel-search?type=$term->tid") . " ($count)"; } if ( count($items) ) { print theme('item_list', $items);} ?>
the problem is in the bolded line, specifically the question mark and equal sign. I get a taxonomy list like this:
retail (3)
accounts (2)
IT (1)
when I hover over these, the links look perfect down in the status bar, but when I click on them, they come out in the URL bar as such:
...personnel-search%3Ftype%3D25
and thus give me a 404. Is there an easy way of encoding it right?
thanks Neil
Thanks for the idea, unfortunately exactly the same problem. The issue is with the ? and = symbols. ----- Original Message ----- From: Jason Minion To: support@drupal.org Sent: Thursday, April 22, 2010 10:27 AM Subject: Re: [support] slight problem with encoding
Have you tried putting the curly braces around the variable call?
“personnel-search?type={$term->tid}”
http://php.net/manual/en/language.types.string.php, scroll down to Variable Parsing.
Jason
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Neil Coghlan Sent: Thursday, April 22, 2010 8:18 AM To: support@drupal.org Subject: Re: [support] slight problem with encoding
no solutions for this?? I've tried everything I can think of...escaping the characters, wrapping them in all sorts of other characters, but no luck.
----- Original Message -----
From: Neil Coghlan
To: support@drupal.org
Sent: Thursday, April 22, 2010 12:32 AM
Subject: slight problem with encoding
I have the following php snippet giving me a list of taxonomy terms for a certain vocab and certain content type.
<?php $vid = 4; $items = array(); $type = manager; $terms = taxonomy_get_tree($vid); foreach ( $terms as $term ) { $count = db_result(db_query("SELECT COUNT(term_node.nid) FROM {term_node} JOIN {node} ON node.nid = term_node.nid WHERE node.type = '%s' AND tid = %d", $type, $term->tid)); $items[] = l($term->name, "personnel-search?type=$term->tid") . " ($count)"; } if ( count($items) ) { print theme('item_list', $items);} ?>
the problem is in the bolded line, specifically the question mark and equal sign. I get a taxonomy list like this:
retail (3)
accounts (2)
IT (1)
when I hover over these, the links look perfect down in the status bar, but when I click on them, they come out in the URL bar as such:
...personnel-search%3Ftype%3D25
and thus give me a 404. Is there an easy way of encoding it right?
thanks
Neil
------------------------------------------------------------------------------
-- [ Drupal support list | http://lists.drupal.org/ ]
Neil Coghlan wrote:
Thanks for the idea, unfortunately exactly the same problem. The issue is with the ? and = symbols.
Yea well, I knew that wouldn't work.
Looking at http://api.drupal.org/api/function/l/6 we see that we should write
$items[] = l($term->name, "personnel-search?type=$term->tid")
as
$items[] = l($term->name, "personnel-search", array('fragment' => type=$term->tid))
The above is untested and you might need 'query' instead of 'fragment'.
getting parse error. Parse error: parse error, expecting `')'' in C:\xampp\htdocs...
can't see any missing brackets. Only changed this line:
$items[] = l($term->name, "personnel-search", array('fragment' => type=$term->tid)) . " ($count)";
----- Original Message ----- From: "Earnie Boyd" earnie@users.sourceforge.net To: support@drupal.org Sent: Thursday, April 22, 2010 11:08 AM Subject: Re: [support] slight problem with encoding
Neil Coghlan wrote:
Thanks for the idea, unfortunately exactly the same problem. The issue is with the ? and = symbols.
Yea well, I knew that wouldn't work.
Looking at http://api.drupal.org/api/function/l/6 we see that we should write
$items[] = l($term->name, "personnel-search?type=$term->tid")
as
$items[] = l($term->name, "personnel-search", array('fragment' => type=$term->tid))
The above is untested and you might need 'query' instead of 'fragment'.
-- Earnie -- http://progw.com
-- http://www.for-my-kids.com
[ Drupal support list | http://lists.drupal.org/ ]
OK, I did some playing around. I need to wrap the query part in single quotes, like this:
$items[] = l($term->name, "personnel-search", array('query' => 'type=$term->tid')) . " ($count)";
this parses now, and the ? and = sign are being passed correctly in the URL when clicking BUT the tid variable is staying as a variable...maybe you can't put variables in the array section. So I'm getting links like this now:
personnel-search?type=$term->tid
perhaps I need to split it off like what's been done with the $count part??
----- Original Message ----- From: "Earnie Boyd" earnie@users.sourceforge.net To: support@drupal.org Sent: Thursday, April 22, 2010 11:08 AM Subject: Re: [support] slight problem with encoding
Neil Coghlan wrote:
Thanks for the idea, unfortunately exactly the same problem. The issue is with the ? and = symbols.
Yea well, I knew that wouldn't work.
Looking at http://api.drupal.org/api/function/l/6 we see that we should write
$items[] = l($term->name, "personnel-search?type=$term->tid")
as
$items[] = l($term->name, "personnel-search", array('fragment' => type=$term->tid))
The above is untested and you might need 'query' instead of 'fragment'.
-- Earnie -- http://progw.com
-- http://www.for-my-kids.com
[ Drupal support list | http://lists.drupal.org/ ]
done it! After playing around, this was the solution:
$items[] = l($term->name, "personnel-search", array('query' => 'type=' . $term->tid)) . "($count)";
I had to split off the $term->tid variable, away from the "type=" part. Seems to work perfectly.
----- Original Message ----- From: "Earnie Boyd" earnie@users.sourceforge.net To: support@drupal.org Sent: Thursday, April 22, 2010 11:08 AM Subject: Re: [support] slight problem with encoding
Neil Coghlan wrote:
Thanks for the idea, unfortunately exactly the same problem. The issue is with the ? and = symbols.
Yea well, I knew that wouldn't work.
Looking at http://api.drupal.org/api/function/l/6 we see that we should write
$items[] = l($term->name, "personnel-search?type=$term->tid")
as
$items[] = l($term->name, "personnel-search", array('fragment' => type=$term->tid))
The above is untested and you might need 'query' instead of 'fragment'.
-- Earnie -- http://progw.com
-- http://www.for-my-kids.com
[ Drupal support list | http://lists.drupal.org/ ]