0

How to use pager or how to limit terms, when using taxonomy_get_tree($vid)?

I have this code for terms generation:

<?php
$vid = 2;
$terms = taxonomy_get_tree($vid);   
$max_depth = (!isset($max_depth)) ? count($children[$vid]) : $max_depth;

foreach ($terms as $term) {
if ($term->depth == 0) 
{  
print "" .l("<b>Auto Insurance for &nbsp;</b> " .$term->name,'taxonomy/term/'.$term->tid, array('attributes' => array('title' => $term->name, ), 'html' => TRUE) ). "";

}}

?>

But there are thousands of terms or sub terms. Some pages are then loading more then 20 seconds. I need to improve this situation.

Can you advice me please? Do you know some solution? Pager, Jquery, Ajax?

0

Add a counter into your for each statement that counts the array index and terminates after X number of items. That'd fix it.

  • Well, that sounds good. But can u show me exactly how? My PHP knowledge is very poor Thank you. – Hefi Aug 9 '14 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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