Hi,

My content is tagged with taxonomy. So in those pages i can see the taxonomy link on top .If i mouse over the that i can see www.mysite.com/taxonomy/term/31 , Is there any way to fetch the 31, i think its tag id and print it in the respective page

Please help to resolve this....

Comments

vijaythummar’s picture

why are you not used arg() funtion for getting arguments? Suppose you need 3 argument from URL then you can use arg(2).

Thanks,
vijay

Thanks,
Vijay Thummar

donkasok’s picture

Hi,

Thanks for the replay... My issue is

I HAVE TWO WEBSITES (www.exam1.com , www.exam2.com) . I created same taxonomy for both websites. both have same vocabulary and terms.
I printed the taxonomy link on page .tpl using the below code.

                                                      if (module_exists('taxonomy')) {
                                $terms = taxonomy_link('taxonomy terms', $node);
                                print theme('links', $terms);
                                                    // print theme($terms);
                              }
                           

The above code is fetching the current page taxonamy (www.exam1.com/taxonomy/term/10). I need to fetch only term/10 or taxonomy/term/10). How can i accomplish this.Please help me.

with regards,
Don

vijaythummar’s picture

Hi from the below code you can get the path of taxonomy.


if (module_exists('taxonomy')) {
                                $terms = taxonomy_link('taxonomy terms', $node);
                                  foreach ($terms as $key => $value) {
                                    $term_path[] = $value['href'];
                                  }
                       print_r($term_path);

Output of this is


Array
(
    [0] => taxonomy/term/7
    [1] => taxonomy/term/4
)

but still i confused that why do you need only these path? And BTW in the print theme('links', $terms) function you have to pass whole $terms not onlt these array else it will not generate path and will through errors.

Regards,
vijay

Thanks,
Vijay Thummar

donkasok’s picture

I need the terms id to accomplish a unusual task.
Currently i am having two website (www.exam1.com , www.exam2.com, www.exam3.com) using domain access module . I created same taxonomy for both websites. both have same vocabulary and terms.

If user is reading an article in www.exam1.com In the bottom page i need to show a link saying that "related topics on exam2 " and "related topics on exam 3" Once he click on "related topics on exam2 " it will navigate into a page "www.exam2.com/taxonomy/term/31". If i am able to retrieve the term id i only need to append it with the respective urls to accomplish this.

with regards,
Don

vijaythummar’s picture

OK so now from above code, your problem is solved, Right? Or you need any more help?

Thanks,
Vijay Thummar

donkasok’s picture

hi thanks 4 ur replay.. i am putting those codes now . i was not around last day .. So i am going to check it now... thanks a lot for your concern

DoN

donkasok’s picture

Hi,

I am having some issues with these codes... While i put all the codes inside page.tpl and refreshed the browser. The entire page disappears. Its not showing any content. Ince i removed the code everything works fine

DoN

dman’s picture

http://api.drupal.org/api/function/taxonomy_node_get_terms/6
gives you a nice array of term data, not the cooked link.

.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |

donkasok’s picture

Hi,

Ho can i use this function in page.tpl.php.

DoN

dman’s picture

Don't do it in page.tpl.php, node information is in node.tpl.php.

print_r(taxonomy_node_get_terms($node));

For more help you will have to demonstrate what you've actually tried so far.
If you haven't tried, you can't be helped.

.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |

donkasok’s picture

Hi,

Thanks a lot its working superb. Its printing an array object. I am so new to this i know this is an array i think this is an multidimensional array i am not sure about it can you please tell me how can i fetch this array objects.

Array ( [30] => stdClass Object ( [tid] => 30 [vid] => 7 [name] => Relatives [description] => [weight] => 0 ) [31] => stdClass Object ( [tid] => 31 [vid] => 7 [name] => Friends [description] => [weight] => 0 ) )

how can i retrieve the term id 30 and 31 and assign to an php variable for example i need to retrive the friends and relatives and assign it to $friends and $relatives , so that i can create a hyperlink 'www.website2.com/taxonomy/term/".$friends."+".$relatives'

DoN

donkasok’s picture

if i use

foreach ($node->taxonomy as $tid) {
print $tid->tid ."+";
}

it will print all the tids, but i need to get the count of tid first so that i cann append each with +

DoN