Page 2 of 3
Re: Lazy meta tags:)
Posted: Thu Oct 29, 2009 7:30 am
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');
}
Re: Lazy meta tags:)
Posted: Thu Oct 29, 2009 3:51 pm
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
Re: Lazy meta tags:)
Posted: Thu Oct 29, 2009 4:31 pm
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?
Re: Lazy meta tags:)
Posted: Thu Oct 29, 2009 4:43 pm
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
Re: Lazy meta tags:)
Posted: Sat Oct 31, 2009 1:03 am
by Ektos.Elenchu
Really great work. Thanx a lot, it finally solved problems my with CGBlog and meta tags.
Re: Lazy meta tags:)
Posted: Mon Apr 26, 2010 6:22 pm
by jwaldeck
Hey Sonya, wie gehts, ich bins wieder!
Any clue how to adapt your great plugin for the Cataloger module??
Tks!
Re: Lazy meta tags:)
Posted: Sun May 16, 2010 7:45 pm
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
Re: Lazy meta tags:)
Posted: Sun May 16, 2010 8:07 pm
by Nullig
It's the Search module that comes as part of the Core - not an additional module.
Nullig
Re: Lazy meta tags:)
Posted: Sun May 16, 2010 9:10 pm
by Kaylen
Ah thank you very much for your answer!
Re: Lazy meta tags:)
Posted: Tue Jul 06, 2010 4:14 pm
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;
}
Re: Lazy meta tags:)
Posted: Sun Feb 13, 2011 1:48 pm
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?
Re: Lazy meta tags:)
Posted: Sun Feb 13, 2011 7:25 pm
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...
Re: Lazy meta tags:)
Posted: Sun Feb 13, 2011 7:41 pm
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¿
Re: Lazy meta tags:)
Posted: Sun Feb 13, 2011 7:42 pm
by Dr.CSS
Try going to the Search module admin and run the re-index...
Re: Lazy meta tags:)
Posted: Sun Feb 13, 2011 7:52 pm
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...