2

I'm using drupal6 taxonomy.The content type 'B' is using a tag field which can use the title of the some of nodes of the content type 'A'.If any node of 'B' tagged a name or title of a node of content type 'A', I want to display one message in the respective node of 'A'.

Alternatively, is there any way to find if www.mysite/category/tag/term doesn't gives the "Page not found" error? This is to find if the term is used, or not.

4 Answers 4

3

If you have the term name, you can use the following code.

$nodes = array();

if ($term = taxonomy_get_term_by_name($term_name)) {
  $result = taxonomy_select_nodes(array($term->tid), 'or', 0, FALSE, 'n.sticky DESC, n.created DESC');
  while ($row = db_fetch_object($result)) {
    $nodes[] = $row->nid;
  }
}

if (!empty($nodes)) {
  // The taxonomy term is used from at least a node.
}
0
2

I think that you could use the function drupal_http_request (in a module or in a template).

This functions returns the response of the request (200 if it's ok, and so on).

1
  • @arrubiu.Thanks for your response,if i want to check this link www.mysite.com/category/tags gives a page not found or not,how to use this drupal_http_request? If my question sounds bad please forgive me.
    – Ranjani
    Jan 3, 2013 at 7:15
2

Try using taxonomy_get_term_by_name('term name'). It should return an empty array if no term is found, so just check with the empty() function.

0
1

First of all I want to thank whom all gave response to my post.And my answer is,I get the title from the url of content type 'A'(wwww.sitename.com/xxx/yyy/title-raw i get the value of title-raw that is the title of that node.) And the taxonomy term page of content type 'B' has the url as www.sitename.com/category/content_type_b_machine_name/term name. so i checked the last term of the taxonomy term page in its url with the title-raw of content-type 'A' If the www.sitename.com/category/content_type_b_machine_name/title-raw-con-type-A doesnot gives a "400" (page not found error)page then the title is used as a taxonomy term.

1
  • If anyone know a better answers than mine,Please don't forget to share with us.
    – Ranjani
    Jan 5, 2013 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.