Nube de tags

Started by Aportadordelmix, April 20, 2010, 11:13:35 AM

Previous topic - Next topic

Aportadordelmix

Hola!

Me gustaria saber si se puede hacer en mi foro version 1.1.11 una nube de tags ya que tengo instalado el mod googletagged.


Si es posible con algun bloque de simpleportal, poner ahi todos los tags mas populares.

Muchas gracias.

Blackdozer

http://simpleportal.net/index.php?topic=1339.msg9270#msg9270
Crea un bloque con el código que te dan hay ;)
Y sino en "blocks y modifications" de la web busca "tag"

Aportadordelmix

El codifo donde lo busco?

Blackdozer

Quote from: aportadordelmix on April 20, 2010, 12:48:49 PM
El codifo donde lo busco?
El código viene en el post que te he dado, me parece que ni te has dignado a mirartelo...

Aportadordelmix

Quote from: Blackdozer on April 20, 2010, 12:50:37 PM
Quote from: aportadordelmix on April 20, 2010, 12:48:49 PM
El codifo donde lo busco?
El código viene en el post que te he dado, me parece que ni te has dignado a mirartelo...

Lo he leido lo que pasa que block hago? con que codigo pongo el codigo, porque yo uso el mod googletaged.


Blackdozer

Haber: Crea un bloque y dentro de hay pones el código ;)

Aportadordelmix

bloque con que codigo? php o html?

global $db_prefix, $modSettings, $context, $scripturl; $result = db_query("SELECT t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity   FROM {$db_prefix}tags as t, {$db_prefix}tags_log as l   WHERE t.ID_TAG = l.ID_TAG   GROUP BY l.ID_TAG   ORDER BY l.ID DESC LIMIT " . $modSettings['smftags_set_cloud_tags_to_show'], __FILE__, __LINE__); $tags = array(); $tags2 = array(); while ($row = mysql_fetch_array($result)) {     $tags[$row['tag']] = $row['quantity'];     $tags2[$row['tag']] = $row['ID_TAG']; } if(count($tags2) > 0) { $max_size = $modSettings['smftags_set_cloud_max_font_size_precent']; // max font size in % $min_size = $modSettings['smftags_set_cloud_min_font_size_precent']; // min font size in % $max_qty = max(array_values($tags)); $min_qty = min(array_values($tags)); $spread = $max_qty - $min_qty; if (0 == $spread) { // we don't want to divide by zero     $spread = 1; } $step = ($max_size - $min_size)/($spread); $context['poptags'] = ''; $row_count = 0; foreach ($tags as $key => $value) { $row_count++;     // calculate CSS font-size     // find the $value in excess of $min_qty     // multiply by the font-size increment ($size)     // and add the $min_size set above     $size = $min_size + (($value - $min_qty) * $step);     // uncomment if you want sizes in whole %:     // $size = ceil($size);     // you'll need to put the link destination in place of the #     // (assuming your tag links to some sort of details page)     $context['poptags'] .= '<a href="' . $scripturl . '?action=tags;tagid=' . $tags2[$key] . '" style="font-size: '.$size.'%"';     // perhaps adjust this title attribute for the things that are tagged    $context['poptags'] .= ' title="'.$value.' things tagged with '.$key.'"';    $context['poptags'] .= '>'.$key.'</a> ';    if ($row_count > $modSettings['smftags_set_cloud_tags_per_row'])    {     $context['poptags'] .= '<br />';     $row_count =0;    }     // notice the space at the end of the link } } echo $context['poptags'];

ese el cod que va adentro bloque?

Blackdozer

Quote from: aportadordelmix on April 20, 2010, 01:52:30 PM
bloque con que codigo? php o html?

global $db_prefix, $modSettings, $context, $scripturl; $result = db_query("SELECT t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity   FROM {$db_prefix}tags as t, {$db_prefix}tags_log as l   WHERE t.ID_TAG = l.ID_TAG   GROUP BY l.ID_TAG   ORDER BY l.ID DESC LIMIT " . $modSettings['smftags_set_cloud_tags_to_show'], __FILE__, __LINE__); $tags = array(); $tags2 = array(); while ($row = mysql_fetch_array($result)) {     $tags[$row['tag']] = $row['quantity'];     $tags2[$row['tag']] = $row['ID_TAG']; } if(count($tags2) > 0) { $max_size = $modSettings['smftags_set_cloud_max_font_size_precent']; // max font size in % $min_size = $modSettings['smftags_set_cloud_min_font_size_precent']; // min font size in % $max_qty = max(array_values($tags)); $min_qty = min(array_values($tags)); $spread = $max_qty - $min_qty; if (0 == $spread) { // we don't want to divide by zero     $spread = 1; } $step = ($max_size - $min_size)/($spread); $context['poptags'] = ''; $row_count = 0; foreach ($tags as $key => $value) { $row_count++;     // calculate CSS font-size     // find the $value in excess of $min_qty     // multiply by the font-size increment ($size)     // and add the $min_size set above     $size = $min_size + (($value - $min_qty) * $step);     // uncomment if you want sizes in whole %:     // $size = ceil($size);     // you'll need to put the link destination in place of the #     // (assuming your tag links to some sort of details page)     $context['poptags'] .= '<a href="' . $scripturl . '?action=tags;tagid=' . $tags2[$key] . '" style="font-size: '.$size.'%"';     // perhaps adjust this title attribute for the things that are tagged    $context['poptags'] .= ' title="'.$value.' things tagged with '.$key.'"';    $context['poptags'] .= '>'.$key.'</a> ';    if ($row_count > $modSettings['smftags_set_cloud_tags_per_row'])    {     $context['poptags'] .= '<br />';     $row_count =0;    }     // notice the space at the end of the link } } echo $context['poptags'];

ese el cod que va adentro bloque?
Si, mira bién que sea para tu versión ;)

lean

Eso es php amigo. O de ultima no te cuesta nada probar con uno o con otro. Ok?

Usa el de php pero para la proxima esta bueno aprender de la prueba y error.
saludos

Blackdozer

Quote from: lean on April 20, 2010, 01:53:59 PM
Eso es php amigo. O de ultima no te cuesta nada probar con uno o con otro. Ok?

Usa el de php pero para la proxima esta bueno aprender de la prueba y error.
saludos
No todo el mundo tienes las mismas ideas o tienen miedo a que se fastidie algo.
Pero tienes toda la razón, de los errores y pruebas se aprende, como yo aprendí, yo aprendí a fallos no a tutoriales xD

Aportadordelmix

Quote from: lean on April 20, 2010, 01:53:59 PM
Eso es php amigo. O de ultima no te cuesta nada probar con uno o con otro. Ok?

Usa el de php pero para la proxima esta bueno aprender de la prueba y error.
saludos

Ya lo habia hecho con php y me salio este error!

Parse error: syntax error, unexpected $end in /home/martin/domains/aportesydescargas.com.ar/public_html/foro/Sources/PortalBlocks.php(3409) : eval()'d code on line 1

lean

Quote from: aportadordelmix on April 20, 2010, 01:57:15 PM
Quote from: lean on April 20, 2010, 01:53:59 PM
Eso es php amigo. O de ultima no te cuesta nada probar con uno o con otro. Ok?

Usa el de php pero para la proxima esta bueno aprender de la prueba y error.
saludos

Ya lo habia hecho con php y me salio este error!

Parse error: syntax error, unexpected $end in /home/martin/domains/aportesydescargas.com.ar/public_html/foro/Sources/PortalBlocks.php(3409) : eval()'d code on line 1

Fijate de copiar todo el codigo porque yo lo probe y anda bien. Aunque cuando haces click en algun tag de los que muestra sale un error puesto que vincula la url donde estas con la url del tag. Pero bueno, eso no seria muy dificil de arreglar. Pero anda

Blackdozer

Algo no copiaste o añadiste algo, vuelve a probar porqué el código tiene que funcionar si o si ;)

Aportadordelmix

Quote from: lean on April 20, 2010, 01:59:12 PM
Quote from: aportadordelmix on April 20, 2010, 01:57:15 PM
Quote from: lean on April 20, 2010, 01:53:59 PM
Eso es php amigo. O de ultima no te cuesta nada probar con uno o con otro. Ok?

Usa el de php pero para la proxima esta bueno aprender de la prueba y error.
saludos

Ya lo habia hecho con php y me salio este error!


Con este codigo pruebo:

global $db_prefix, $modSettings, $context, $scripturl;      $result = db_query("SELECT t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity        FROM {$db_prefix}tags as t, {$db_prefix}tags_log as l         WHERE t.ID_TAG = l.ID_TAG         GROUP BY l.ID_TAG        ORDER BY l.ID DESC LIMIT " . $modSettings['smftags_set_cloud_tags_to_show'], __FILE__, __LINE__);            $tags = array();            $tags2 = array();            while ($row = mysql_fetch_array($result))       {          $tags[$row['tag']] = $row['quantity'];          $tags2[$row['tag']] = $row['ID_TAG'];      }            if(count($tags2) > 0)      {         $max_size = $modSettings['smftags_set_cloud_max_font_size_precent']; // max font size in %         $min_size = $modSettings['smftags_set_cloud_min_font_size_precent']; // min font size in %         $max_qty = max(array_values($tags));         $min_qty = min(array_values($tags));                  $spread = $max_qty - $min_qty;         if (0 == $spread)          { // we don't want to divide by zero             $spread = 1;         }                  $step = ($max_size - $min_size)/($spread);                  $context['poptags'] = '';         $row_count = 0;         foreach ($tags as $key => $value)          {            $row_count++;             // calculate CSS font-size             // find the $value in excess of $min_qty             // multiply by the font-size increment ($size)             // and add the $min_size set above             $size = $min_size + (($value - $min_qty) * $step);             // uncomment if you want sizes in whole %:             // $size = ceil($size);                      // you'll need to put the link destination in place of the #             // (assuming your tag links to some sort of details page)             $context['poptags'] .= '<a href="' . $scripturl . '?action=tags;tagid=' . $tags2[$key] . '" style="font-size: '.$size.'%"';             // perhaps adjust this title attribute for the things that are tagged            $context['poptags'] .= ' title="'.$value.' things tagged with '.$key.'"';            $context['poptags'] .= '>'.$key.'</a> ';            if ($row_count > $modSettings['smftags_set_cloud_tags_per_row'])            {               $context['poptags'] .= '<br />';               $row_count =0;            }             // notice the space at the end of the link         }      }      echo $context['poptags'];


Y me sale el error anterior que puse. Eso haciendolo con bloque de php.

Parse error: syntax error, unexpected $end in /home/martin/domains/aportesydescargas.com.ar/public_html/foro/Sources/PortalBlocks.php(3409) : eval()'d code on line 1

Fijate de copiar todo el codigo porque yo lo probe y anda bien. Aunque cuando haces click en algun tag de los que muestra sale un error puesto que vincula la url donde estas con la url del tag. Pero bueno, eso no seria muy dificil de arreglar. Pero anda

Blackdozer

Haber, puede que te hayas equivocado al elegir el código, es este:

      global $db_prefix, $modSettings, $context, $scripturl;

      $result = db_query("SELECT t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity
        FROM {$db_prefix}tags as t, {$db_prefix}tags_log as l
        WHERE t.ID_TAG = l.ID_TAG
        GROUP BY l.ID_TAG
        ORDER BY l.ID DESC LIMIT " . $modSettings['smftags_set_cloud_tags_to_show'], __FILE__, __LINE__);
     
      $tags = array();
     
      $tags2 = array();
     
      while ($row = mysql_fetch_array($result))
      {
          $tags[$row['tag']] = $row['quantity'];
          $tags2[$row['tag']] = $row['ID_TAG'];
      }
     
      if(count($tags2) > 0)
      {
         $max_size = $modSettings['smftags_set_cloud_max_font_size_precent']; // max font size in %
         $min_size = $modSettings['smftags_set_cloud_min_font_size_precent']; // min font size in %

         $max_qty = max(array_values($tags));
         $min_qty = min(array_values($tags));
         
         $spread = $max_qty - $min_qty;
         if (0 == $spread)
          { // we don't want to divide by zero
             $spread = 1;
         }
         
         $step = ($max_size - $min_size)/($spread);
         
         $context['poptags'] = '';
         $row_count = 0;
         foreach ($tags as $key => $value)
         {
            $row_count++;
             // calculate CSS font-size
             // find the $value in excess of $min_qty
             // multiply by the font-size increment ($size)
             // and add the $min_size set above
             $size = $min_size + (($value - $min_qty) * $step);
             // uncomment if you want sizes in whole %:
             // $size = ceil($size);
         
             // you'll need to put the link destination in place of the #
             // (assuming your tag links to some sort of details page)
             $context['poptags'] .= '<a href="' . $scripturl . '?action=tags;tagid=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
             // perhaps adjust this title attribute for the things that are tagged
            $context['poptags'] .= ' title="'.$value.' things tagged with '.$key.'"';
            $context['poptags'] .= '>'.$key.'</a> ';
            if ($row_count > $modSettings['smftags_set_cloud_tags_per_row'])
            {
               $context['poptags'] .= '<br />';
               $row_count =0;
            }
             // notice the space at the end of the link
         }
      }

      echo $context['poptags'];


Pón ese código, ya que ese código tiene que funcionar, si incluso lo ha probado lean ;)

Aportadordelmix

Quote from: Blackdozer on April 20, 2010, 02:08:08 PM
Haber, puede que te hayas equivocado al elegir el código, es este:

      global $db_prefix, $modSettings, $context, $scripturl;

      $result = db_query("SELECT t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity
        FROM {$db_prefix}tags as t, {$db_prefix}tags_log as l
        WHERE t.ID_TAG = l.ID_TAG
        GROUP BY l.ID_TAG
        ORDER BY l.ID DESC LIMIT " . $modSettings['smftags_set_cloud_tags_to_show'], __FILE__, __LINE__);
     
      $tags = array();
     
      $tags2 = array();
     
      while ($row = mysql_fetch_array($result))
      {
          $tags[$row['tag']] = $row['quantity'];
          $tags2[$row['tag']] = $row['ID_TAG'];
      }
     
      if(count($tags2) > 0)
      {
         $max_size = $modSettings['smftags_set_cloud_max_font_size_precent']; // max font size in %
         $min_size = $modSettings['smftags_set_cloud_min_font_size_precent']; // min font size in %

         $max_qty = max(array_values($tags));
         $min_qty = min(array_values($tags));
         
         $spread = $max_qty - $min_qty;
         if (0 == $spread)
          { // we don't want to divide by zero
             $spread = 1;
         }
         
         $step = ($max_size - $min_size)/($spread);
         
         $context['poptags'] = '';
         $row_count = 0;
         foreach ($tags as $key => $value)
         {
            $row_count++;
             // calculate CSS font-size
             // find the $value in excess of $min_qty
             // multiply by the font-size increment ($size)
             // and add the $min_size set above
             $size = $min_size + (($value - $min_qty) * $step);
             // uncomment if you want sizes in whole %:
             // $size = ceil($size);
         
             // you'll need to put the link destination in place of the #
             // (assuming your tag links to some sort of details page)
             $context['poptags'] .= '<a href="' . $scripturl . '?action=tags;tagid=' . $tags2[$key] . '" style="font-size: '.$size.'%"';
             // perhaps adjust this title attribute for the things that are tagged
            $context['poptags'] .= ' title="'.$value.' things tagged with '.$key.'"';
            $context['poptags'] .= '>'.$key.'</a> ';
            if ($row_count > $modSettings['smftags_set_cloud_tags_per_row'])
            {
               $context['poptags'] .= '<br />';
               $row_count =0;
            }
             // notice the space at the end of the link
         }
      }

      echo $context['poptags'];


Pón ese código, ya que ese código tiene que funcionar, si incluso lo ha probado lean ;)

Ahora con este codigo me sale en blanco en el bloque, solo el titulo nomas veo.


Blackdozer

Entonces el otro código lo habias cogido mal o no era el correcto, assegurate que lo has codigo entero, dame el código que has puesto dentro del bloque

Aportadordelmix

global $db_prefix, $modSettings, $context, $scripturl;      $result = db_query("SELECT t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity        FROM {$db_prefix}tags as t, {$db_prefix}tags_log as l        WHERE t.ID_TAG = l.ID_TAG        GROUP BY l.ID_TAG        ORDER BY l.ID DESC LIMIT " . $modSettings['smftags_set_cloud_tags_to_show'], __FILE__, __LINE__);            $tags = array();            $tags2 = array();            while ($row = mysql_fetch_array($result))      {          $tags[$row['tag']] = $row['quantity'];          $tags2[$row['tag']] = $row['ID_TAG'];      }

Ese es el codigo.

lean

Estas copiando un cuarto del codigo completo. Fijate bien...  :'( :'(

Aportadordelmix

Quote from: lean on April 20, 2010, 02:21:23 PM
Estas copiando un cuarto del codigo completo. Fijate bien...  :'( :'(

Pero ese el codifgo que me paso black.

global $db_prefix, $modSettings, $context, $scripturl;      $result = db_query("SELECT t.tag AS tag, l.ID_TAG, COUNT(l.ID_TAG) AS quantity        FROM {$db_prefix}tags as t, {$db_prefix}tags_log as l        WHERE t.ID_TAG = l.ID_TAG        GROUP BY l.ID_TAG        ORDER BY l.ID DESC LIMIT " . $modSettings['smftags_set_cloud_tags_to_show'], __FILE__, __LINE__);            $tags = array();            $tags2 = array();            while ($row = mysql_fetch_array($result))      {          $tags[$row['tag']] = $row['quantity'];          $tags2[$row['tag']] = $row['ID_TAG'];      }

Advertisement: