Lazy meta tags:)

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Sonya

Re: Lazy meta tags:)

Post by Sonya »

jwaldeck wrote: But, I'd like to ask you how I should use it with CGBlog Module, any clue?!
Hi,

you have to open function.autometa.php for edit and add these lines about the line 50 (just below News module), then it should work the same way, it works with News.

Code: Select all

		if ($modulename == 'CGBlog') {
			$extra_attr = 'cgblog';
			$module_name = 'CGBlog';
			$content_id = $_REQUEST[$id.'articleid'];
			$desc = $smarty->get_template_vars('autodescription');
		}  
jwaldeck

Re: Lazy meta tags:)

Post by jwaldeck »

Hi Sonya!

Tks for your prompt reply! (das wahr sehr schnell!:)

For some reason, it's only showing the keywords after I include the script inside the tag:

Code: Select all

	$desc = '';

	# if News
	if (isset($_REQUEST['mact'])) {
		$ary = explode(',', $_REQUEST['mact'], 4);
		$modulename = (isset($ary[0])?$ary[0]:'');
		$id = (isset($ary[1])?$ary[1]:'');
		if ($modulename == 'News') {
			$extra_attr = 'article';
			$module_name = 'News';
			$content_id = $_REQUEST[$id.'articleid'];
			$desc = $smarty->get_template_vars('autodescription');
		}
	# if CGBlog
	if ($modulename == 'CGBlog') {
			$extra_attr = 'cgblog';
			$module_name = 'CGBlog';
			$content_id = $_REQUEST[$id.'articleid'];
			$desc = $smarty->get_template_vars('autodescription');
		} 
	
	} 
When I look at other pages, autometa brings me the description as well.. Weird! :(

Tks!
jw
Sonya

Re: Lazy meta tags:)

Post by Sonya »

jwaldeck wrote: Hi Sonya!

Tks for your prompt reply! (das wahr sehr schnell!:)
Bitte :)
jwaldeck wrote: For some reason, it's only showing the keywords after I include the script inside the tag:
.....
When I look at other pages, autometa brings me the description as well.. Weird! :(
Have you added

Code: Select all

{assign var='autodescription' value=$entry->content}
at the very top of the Detail View Template in CGBlog?
jwaldeck

Re: Lazy meta tags:)

Post by jwaldeck »

OK, now THAT was stupid, sorry!  :'(

I've added it before and since it wasn't working I created a new var and called it on the description tag and took this one away. And guess what? Forgot to put it back!

Now it's working VERY WELL!!!

Tks a lot again for your help once again! Anything you need, let me know.

Cheers,
jw
Ektos.Elenchu
New Member
New Member
Posts: 6
Joined: Thu Mar 05, 2009 10:40 am
Location: Czech Republic, sometimes Greece

Re: Lazy meta tags:)

Post by Ektos.Elenchu »

Really great work. Thanx a lot, it finally solved problems my with CGBlog and meta tags.
Tux mihi ancora.
jwaldeck

Re: Lazy meta tags:)

Post by jwaldeck »

Hey Sonya, wie gehts, ich bins wieder! :)

Any clue how to adapt your great plugin for the Cataloger module??

Tks!
Kaylen
Forum Members
Forum Members
Posts: 128
Joined: Mon May 01, 2006 5:24 pm

Re: Lazy meta tags:)

Post by Kaylen »

Hi Sonya,

Super module you created!

I have one question though, perhaps a stupid one sorry, but the search module you are referring to, which search module would that be?

I am new and when I look in the module download section under "S" I don't see a search module to download...

Many thanks in advance!

regards,
Kaylen
Last edited by Kaylen on Sun May 16, 2010 7:54 pm, edited 1 time in total.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: Lazy meta tags:)

Post by Nullig »

It's the Search module that comes as part of the Core - not an additional module.

Nullig
Kaylen
Forum Members
Forum Members
Posts: 128
Joined: Mon May 01, 2006 5:24 pm

Re: Lazy meta tags:)

Post by Kaylen »

Ah thank you very much for your answer!
jpatti
Forum Members
Forum Members
Posts: 41
Joined: Mon Jun 28, 2010 1:43 am

Re: Lazy meta tags:)

Post by jpatti »

Sonya, autometa rocks.

I have installed it, but also wanted to do something else.  I wanted to be able to extract the keywords for use elsewhere.  This is tricky because I don't know if the page had keywords or if they were generated by autometa. 

So I adjusted function.autometa.php to make function.keywords.php - and it may not be the prettiest code, as I am unsure of the CMSMS architecture just yet so it may have unnecessary bits, but it works.

If someone wants to use it, feel free.  It's a blatant ripoff of Sonya's code to a slightly different purpose. 

Copy-and-paste this to a file called function.keywords.php and stick it in your plugins directory and call it by typing {keywords} wherever in your template.. 

Code: Select all

<?php
#written by ornery-geeks.org for CMSMS based on code from function.autometa.php by Sonya

function smarty_cms_function_keywords($params, &$smarty) {
   global $gCms;
   # params
   $wordcount = isset($params['key_number']) ? $params['key_number'] : 10;
   $wordlength = isset($params['key_length']) ? $params['key_length']:5;
   $worddensity = isset($params['key_density'])?$params['key_density']:4;
   $keywords = (isset($params['keywords']) && !$params['keywords'])?0:1;
   $addkeys = array();

   if (isset($params['key_add'])) {
      $x = explode(',', $params['key_add']);
      foreach ($x as $key) {
         $addkeys[] = trim($key);
      }
   }

   if (!isset($content_id) || empty($content_id)) {
      $extra_attr = 'content';
      $module_name = 'Search';
      $content_id = $gCms->variables['content_id'];

      $manager =& $gCms->GetHierarchyManager();
      $node =& $manager->getNodeById($gCms->variables['content_id']);
      if( !isset($node) || $node === FALSE ) return;
      $content =& $node->Getcontent();
      $pageinfo = &$gCms->variables['pageinfo'];
      preg_match_all("|<meta[^>]+name=\"([^\"]*)\"[^>]+content=\"([^\"]*)\"[^>]+>|i",
      $pageinfo->content_metadata, $preg_array, PREG_SET_ORDER);

      // find existing meta data
      $found_meta = array();
      if (!empty($preg_array)) {
         foreach($preg_array as $meta) {
            $found_meta[$meta[1]] =  $meta[2];
         }
      }
   }

   $do_keywords = isset($found_meta['keywords'])?false:true;

   $keywordlist = $found_meta['keywords'];

    if ($do_keywords && $keywords) {
      if (CmsModule::GetModuleInstance('Search')) {
         $db = $gCms->db;
         $query = 'SELECT b.word
               FROM '.cms_db_prefix().'module_search_items a,
                    '.cms_db_prefix().'module_search_index b
              WHERE a.content_id = ?
                AND a.module_name = ?
                AND a.extra_attr = ?
                AND a.id = b.item_id
                AND length(b.word) >= ?
              AND b.count >= ?
          ORDER BY b.count DESC';

         $dbr = $db->SelectLimit( $query, $wordcount, 0, array($content_id, $module_name, $extra_attr, $wordlength, $worddensity));

         $wordlist = array();
         while( $dbr && ($row = $dbr->FetchRow() ) )
         {
            $wordlist[] = strip_tags(str_replace('"','',$row['word']));
         }
         $addkeys = array_diff($addkeys,$wordlist);
         $wordlist = array_merge($addkeys, $wordlist);
         if (!empty($wordlist)) {
            $keywordlist = implode(', ',$wordlist);
         }
      }
   }

   echo $keywordlist;

}
bunker
Forum Members
Forum Members
Posts: 30
Joined: Wed Mar 18, 2009 5:59 pm

Re: Lazy meta tags:)

Post by bunker »

Hi all,

Ive implemented {autometa} on a new website that i just changed the template, the style sheet and the content of an old website. That means that I copyed one working site to another server then i began to change everything.

{autometa} for some reason is showing meta description from the old content. Keywords seam to be ok.

Ive emptied cache and also emptied /tmp/templates_c

Any tool to optimize the data base and remove old date? From phpmyadmin I dont have permission to a lot of stuff.... Any other ideas?
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Lazy meta tags:)

Post by Dr.CSS »

If you have old data it most likely comes from not re-indexing the site in Search module, as I think this is using search to generate them...
bunker
Forum Members
Forum Members
Posts: 30
Joined: Wed Mar 18, 2009 5:59 pm

Re: Lazy meta tags:)

Post by bunker »

Dr.CSS wrote:If you have old data it most likely comes from not re-indexing the site in Search module, as I think this is using search to generate them...
In {autometa} help I can read: Keywords are taken from Search module. Description includes first characters of the page content.

In the DB I have found in table cms_content_props and in some other tables some of the text included in the generated meta description.... Why arnt these tables upto date with the modified content? Is the cmsmadesimple DB not optimized?

Also run Piratos Database Optimizer.. no change...

Any ideas¿
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Lazy meta tags:)

Post by Dr.CSS »

Try going to the Search module admin and run the re-index...
bunker
Forum Members
Forum Members
Posts: 30
Joined: Wed Mar 18, 2009 5:59 pm

Re: Lazy meta tags:)

Post by bunker »

Dr.CSS wrote:Try going to the Search module admin and run the re-index...
Allready done.... ;( That would solve any possible problems with the keywords. My problem is with the description...

Im going to check in the function code...
Locked

Return to “Modules/Add-Ons”